<HTML><HEAD><META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type"/><TITLE>EMMA Coverage Report</TITLE><STYLE TYPE="text/css"> TABLE,TD,TH {border-style:solid; border-color:black;} TD,TH {background:white;margin:0;line-height:100%;padding-left:0.5em;padding-right:0.5em;} TD {border-width:0 1px 0 0;} TH {border-width:1px 1px 1px 0;} TR TD.h {color:red;} TABLE {border-spacing:0; border-collapse:collapse;border-width:0 0 1px 1px;} P,H1,H2,H3,TH {font-family:verdana,arial,sans-serif;font-size:10pt;} TD {font-family:courier,monospace;font-size:10pt;} TABLE.hdft {border-spacing:0;border-collapse:collapse;border-style:none;} TABLE.hdft TH,TABLE.hdft TD {border-style:none;line-height:normal;} TABLE.hdft TH.tl,TABLE.hdft TD.tl {background:#6699CC;color:white;} TABLE.hdft TD.nv {background:#6633DD;color:white;} .nv A:link {color:white;} .nv A:visited {color:white;} .nv A:active {color:yellow;} TABLE.hdft A:link {color:white;} TABLE.hdft A:visited {color:white;} TABLE.hdft A:active {color:yellow;} .in {color:#356085;} TABLE.s TD {padding-left:0.25em;padding-right:0.25em;} TABLE.s TD.l {padding-left:0.25em;padding-right:0.25em;text-align:right;background:#F0F0F0;} TABLE.s TR.z TD {background:#FF9999;} TABLE.s TR.p TD {background:#FFFF88;} TABLE.s TR.c TD {background:#CCFFCC;} A:link {color:#0000EE;text-decoration:none;} A:visited {color:#0000EE;text-decoration:none;} A:hover {color:#0000EE;text-decoration:underline;} TABLE.cn {border-width:0 0 1px 0;} TABLE.s {border-width:1px 0 1px 1px;} TD.h {color:red;border-width:0 1px 0 0;} TD.f {border-width:0 1px 0 1px;} TD.hf {color:red;border-width:0 1px 0 1px;} TH.f {border-width:1px 1px 1px 1px;} TR.cis TD {background:#F0F0F0;} TR.cis TD {border-width:1px 1px 1px 0;} TR.cis TD.h {color:red;border-width:1px 1px 1px 0;} TR.cis TD.f {border-width:1px 1px 1px 1px;} TR.cis TD.hf {color:red;border-width:1px 1px 1px 1px;} TD.b {border-style:none;background:transparent;line-height:50%;}  TD.bt {border-width:1px 0 0 0;background:transparent;line-height:50%;} TR.o TD {background:#F0F0F0;}TABLE.it {border-style:none;}TABLE.it TD,TABLE.it TH {border-style:none;}</STYLE></HEAD><BODY><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="tl"><A HREF="http://www.eclemma.org/">EMMA</A> Coverage Report (generated Mon Apr 12 15:12:01 MDT 2010)</TH></TR><TR><TD CLASS="nv">[<A HREF="../cs340omegaReportApril.html">all classes</A>][<A HREF="3.html">Phase2</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">Node.java</SPAN>]</H2><TABLE CELLSPACING="0" WIDTH="100%"><TR><TH>name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD>Node.java</TD><TD>100% (1/1)</TD><TD>89%  (55/62)</TD><TD>88%  (2207/2517)</TD><TD>84%  (460.9/547)</TD></TR></TABLE><H3>COVERAGE BREAKDOWN BY CLASS AND METHOD</H3><TABLE CLASS="cn" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="f">name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD></TR><TR CLASS="cis"><TD CLASS="f">class <A HREF="#0">Node</A></TD><TD>100% (1/1)</TD><TD>89%  (55/62)</TD><TD>88%  (2207/2517)</TD><TD>84%  (460.9/547)</TD></TR><TR><TD CLASS="f"><A HREF="#1">Node (int): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/6)</TD><TD CLASS="h">0%   (0/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">addDownPointers (NodeList): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/16)</TD><TD CLASS="h">0%   (0/5)</TD></TR><TR><TD CLASS="f"><A HREF="#3">addUpPointers (NodeList): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/16)</TD><TD CLASS="h">0%   (0/5)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">getProxy (): NodeProxy</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/8)</TD><TD CLASS="h">0%   (0/1)</TD></TR><TR><TD CLASS="f"><A HREF="#5">init (int): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/9)</TD><TD CLASS="h">0%   (0/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">setWholePayload (Map): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/4)</TD><TD CLASS="h">0%   (0/2)</TD></TR><TR><TD CLASS="f"><A HREF="#7">writeReplace (): Object</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/10)</TD><TD CLASS="h">0%   (0/2)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#8">setOldFold (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">55%  (12/22)</TD><TD CLASS="h">74%  (4.4/6)</TD></TR><TR><TD CLASS="f"><A HREF="#9">setFold (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">57%  (12/21)</TD><TD CLASS="h">74%  (4.4/6)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#a">insert (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">60%  (15/25)</TD><TD CLASS="h">66%  (5.2/8)</TD></TR><TR><TD CLASS="f"><A HREF="#b">setDownPointer (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">61%  (14/23)</TD><TD CLASS="h">74%  (4.4/6)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#c">setUpPointer (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">61%  (14/23)</TD><TD CLASS="h">74%  (4.4/6)</TD></TR><TR><TD CLASS="f"><A HREF="#d">addNeighbour (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">62%  (15/24)</TD><TD CLASS="h">71%  (4.2/6)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#e">goRight (Node, boolean): NodeOrRange</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">64%  (16/25)</TD><TD CLASS="h">65%  (3.2/5)</TD></TR><TR><TD CLASS="f"><A HREF="#f">beingModified (boolean): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">71%  (35/49)</TD><TD CLASS="h">72%  (10.8/15)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#10">getDownPointers (boolean): NodeList</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">75%  (9/12)</TD><TD CLASS="h">67%  (2/3)</TD></TR><TR><TD CLASS="f"><A HREF="#11">getFold (boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">75%  (9/12)</TD><TD CLASS="h">67%  (2/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#12">getNeighbours (boolean): NodeList</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">75%  (9/12)</TD><TD CLASS="h">67%  (2/3)</TD></TR><TR><TD CLASS="f"><A HREF="#13">getState (boolean): NodeState</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">75%  (9/12)</TD><TD CLASS="h">67%  (2/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#14">getUpPointers (boolean): NodeList</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">75%  (9/12)</TD><TD CLASS="h">67%  (2/3)</TD></TR><TR><TD CLASS="f"><A HREF="#15">removeUp (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">78%  (21/27)</TD><TD>89%  (6.2/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#16">setId (int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">79%  (11/14)</TD><TD>80%  (4/5)</TD></TR><TR><TD CLASS="f"><A HREF="#17">setState (NodeState): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">79%  (11/14)</TD><TD>80%  (4/5)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#18">compareTo (Node): int</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>80%  (28/35)</TD><TD>81%  (7.2/9)</TD></TR><TR><TD CLASS="f"><A HREF="#19">addNeighbours (NodeList): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>81%  (13/16)</TD><TD>80%  (4/5)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#1a">getParent (boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>82%  (31/38)</TD><TD CLASS="h">67%  (6/9)</TD></TR><TR><TD CLASS="f"><A HREF="#1b">releaseAccessPriviledge (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>83%  (15/18)</TD><TD>80%  (4/5)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#1c">getChild (boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>84%  (76/91)</TD><TD>80%  (20/25)</TD></TR><TR><TD CLASS="f"><A HREF="#1d">getInsertionLock (): boolean</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (12/14)</TD><TD CLASS="h">75%  (3/4)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#1e">setDownPointers (NodeList): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (18/21)</TD><TD>83%  (5/6)</TD></TR><TR><TD CLASS="f"><A HREF="#1f">setNeighbours (NodeList): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (18/21)</TD><TD>83%  (5/6)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#20">setUpPointers (NodeList): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (18/21)</TD><TD>83%  (5/6)</TD></TR><TR><TD CLASS="f"><A HREF="#21">acquireAccessPriviledge (boolean): boolean</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>87%  (13/15)</TD><TD CLASS="h">75%  (3/4)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#0">&lt;static initializer&gt;</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>88%  (7/8)</TD><TD>87%  (0.9/1)</TD></TR><TR><TD CLASS="f"><A HREF="#23">getHeight (boolean): int</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>90%  (26/29)</TD><TD>86%  (6/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#24">find (int, Node, boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>90%  (71/79)</TD><TD>95%  (14.2/15)</TD></TR><TR><TD CLASS="f"><A HREF="#25">getInsertionPoint (): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>91%  (85/93)</TD><TD>85%  (17/20)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#26">remove (): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>91%  (247/270)</TD><TD>88%  (48.2/55)</TD></TR><TR><TD CLASS="f"><A HREF="#27">getNeighbour (int, boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>92%  (34/37)</TD><TD>90%  (9/10)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#28">giveMeChild (boolean): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>92%  (36/39)</TD><TD>88%  (7/8)</TD></TR><TR><TD CLASS="f"><A HREF="#29">getLastNode (): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>94%  (32/34)</TD><TD>86%  (6/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2a">toString (): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>95%  (192/203)</TD><TD>86%  (13.8/16)</TD></TR><TR><TD CLASS="f"><A HREF="#2b">renewState (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>95%  (53/56)</TD><TD>92%  (11/12)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2c">performInsert (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>95%  (318/333)</TD><TD>93%  (62.9/68)</TD></TR><TR><TD CLASS="f"><A HREF="#2d">replaceNode (Node): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>97%  (179/185)</TD><TD>98%  (34.2/35)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2e">insertionFoldSetup (Node, Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>99%  (68/69)</TD><TD>99%  (14.9/15)</TD></TR><TR><TD CLASS="f"><A HREF="#2f">Node (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (5/5)</TD><TD>100% (3/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#30">accept (Visitor, Object): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (6/6)</TD><TD>100% (2/2)</TD></TR><TR><TD CLASS="f"><A HREF="#31">acceptWithResponse (Visitor, Object): Object</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (5/5)</TD><TD>100% (1/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#32">allNodes (ArrayList, int): NodeList</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (43/43)</TD><TD>100% (8/8)</TD></TR><TR><TD CLASS="f"><A HREF="#33">getGlobalID (): GlobalID</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (3/3)</TD><TD>100% (1/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#34">getId (boolean): int</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (3/3)</TD><TD>100% (1/1)</TD></TR><TR><TD CLASS="f"><A HREF="#35">getOldFold (): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (3/3)</TD><TD>100% (1/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#36">getPayload (String): Object</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (5/5)</TD><TD>100% (1/1)</TD></TR><TR><TD CLASS="f"><A HREF="#37">getWholePayload (): Map</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (3/3)</TD><TD>100% (1/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#38">init (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (65/65)</TD><TD>100% (15/15)</TD></TR><TR><TD CLASS="f"><A HREF="#39">printAllNode (): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (59/59)</TD><TD>100% (10/10)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#3a">printMessage (String): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (15/15)</TD><TD>100% (2/2)</TD></TR><TR><TD CLASS="f"><A HREF="#3b">removeFold (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (45/45)</TD><TD>100% (12/12)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#3c">removeLastNode (): Node</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (82/82)</TD><TD>100% (18/18)</TD></TR><TR><TD CLASS="f"><A HREF="#3d">removeNeighbor (Node): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (48/48)</TD><TD>100% (11/11)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#3e">setPayload (String, Object): Object</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (6/6)</TD><TD>100% (1/1)</TD></TR></TABLE><P></P><TABLE CLASS="s" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="l">1</TD><TD>package Phase2;</TD></TR><TR><TD CLASS="l">2</TD><TD> </TD></TR><TR><TD CLASS="l">3</TD><TD>import java.io.FileOutputStream;</TD></TR><TR><TD CLASS="l">4</TD><TD>import java.io.ObjectStreamException;</TD></TR><TR><TD CLASS="l">5</TD><TD>import java.io.Serializable;</TD></TR><TR><TD CLASS="l">6</TD><TD>import java.util.Iterator;</TD></TR><TR><TD CLASS="l">7</TD><TD>import Phase1.GlobalID;</TD></TR><TR><TD CLASS="l">8</TD><TD> </TD></TR><TR><TD CLASS="l">9</TD><TD>import java.util.ArrayList;</TD></TR><TR><TD CLASS="l">10</TD><TD>import java.util.Map;</TD></TR><TR><TD CLASS="l">11</TD><TD>import java.util.HashMap;</TD></TR><TR><TD CLASS="l">12</TD><TD>import java.util.concurrent.Semaphore;</TD></TR><TR><TD CLASS="l">13</TD><TD> </TD></TR><TR><TD CLASS="l">14</TD><TD>import org.junit.Assert;</TD></TR><TR><TD CLASS="l">15</TD><TD> </TD></TR><TR><TD CLASS="l">16</TD><TD>import plugin.Visitor;</TD></TR><TR><TD CLASS="l">17</TD><TD> </TD></TR><TR><TD CLASS="l">18</TD><TD>/**</TD></TR><TR><TD CLASS="l">19</TD><TD> * </TD></TR><TR><TD CLASS="l">20</TD><TD> * A member of a HyPeerWeb with a binary identifier</TD></TR><TR><TD CLASS="l">21</TD><TD> * </TD></TR><TR><TD CLASS="l">22</TD><TD> * @author rpadilla</TD></TR><TR><TD CLASS="l">23</TD><TD> * </TD></TR><TR><TD CLASS="l">24</TD><TD> * @domain</TD></TR><TR><TD CLASS="l">25</TD><TD> *         id                                 : Integer &gt;= 0</TD></TR><TR><TD CLASS="l">26</TD><TD> *         neighbours                 : NodeList</TD></TR><TR><TD CLASS="l">27</TD><TD> *         upPointers                 : NodeList</TD></TR><TR><TD CLASS="l">28</TD><TD> *         downPointers         : NodeList</TD></TR><TR><TD CLASS="l">29</TD><TD> *         fold                         : Node</TD></TR><TR><TD CLASS="l">30</TD><TD> *         oldFold                 : Node</TD></TR><TR><TD CLASS="l">31</TD><TD> *         globalID                : GlobalID</TD></TR><TR><TD CLASS="l">32</TD><TD> * </TD></TR><TR><TD CLASS="l"><A NAME="0">33</A></TD><TD> * </TD></TR><TR><TD CLASS="l">34</TD><TD> *</TD></TR><TR><TD CLASS="l">35</TD><TD> */</TD></TR><TR><TD CLASS="l">36</TD><TD> </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="88% line coverage (7 out of 8 instructions)">37</TD><TD TITLE="88% line coverage (7 out of 8 instructions)">public class Node implements NodeOrRange, Comparable&lt;Node&gt;, Serializable</TD></TR><TR><TD CLASS="l">38</TD><TD>{</TD></TR><TR><TD CLASS="l">39</TD><TD>        private static final long serialVersionUID = 1L;</TD></TR><TR><TD CLASS="l">40</TD><TD>        protected GlobalID globalID;</TD></TR><TR><TD CLASS="l">41</TD><TD>        protected int id;</TD></TR><TR><TD CLASS="l">42</TD><TD>        private volatile Semaphore access;</TD></TR><TR><TD CLASS="l">43</TD><TD>        private volatile Semaphore modifyingCommands;</TD></TR><TR><TD CLASS="l">44</TD><TD>        private Node fold;</TD></TR><TR><TD CLASS="l">45</TD><TD>        private Node oldFold;        </TD></TR><TR><TD CLASS="l">46</TD><TD>        private NodeList up;</TD></TR><TR><TD CLASS="l">47</TD><TD>        private NodeList down;</TD></TR><TR><TD CLASS="l">48</TD><TD>        private NodeList neighbours;</TD></TR><TR><TD CLASS="l">49</TD><TD>        private NodeState state;</TD></TR><TR><TD CLASS="l">50</TD><TD>        private Map&lt;String, Object&gt; payload;</TD></TR><TR><TD CLASS="l">51</TD><TD>        private boolean beingModified;</TD></TR><TR><TD CLASS="l">52</TD><TD>        private volatile int accessingData;</TD></TR><TR><TD CLASS="l">53</TD><TD>        </TD></TR><TR><TD CLASS="l">54</TD><TD>        </TD></TR><TR><TD CLASS="l">55</TD><TD>        /**</TD></TR><TR><TD CLASS="l"><A NAME="2f">56</A></TD><TD>         * default constructor</TD></TR><TR><TD CLASS="l">57</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l">58</TD><TD>         * @post all lists are instantiated and folds are assigned to null</TD></TR><TR><TD CLASS="l">59</TD><TD>         */</TD></TR><TR CLASS="c"><TD CLASS="l">60</TD><TD>        public Node()</TD></TR><TR><TD CLASS="l">61</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">62</TD><TD>                this.init();</TD></TR><TR CLASS="c"><TD CLASS="l">63</TD><TD>        }</TD></TR><TR><TD CLASS="l">64</TD><TD>        </TD></TR><TR><TD CLASS="l">65</TD><TD>        /**</TD></TR><TR><TD CLASS="l"><A NAME="1">66</A></TD><TD>         * @param port - the port to which the node's globalID should be attached to</TD></TR><TR><TD CLASS="l">67</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l">68</TD><TD>         * @post all lists are instantiated and folds are assigned to null</TD></TR><TR><TD CLASS="l">69</TD><TD>         */</TD></TR><TR CLASS="z"><TD CLASS="l">70</TD><TD>        public Node(int port)</TD></TR><TR><TD CLASS="l">71</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">72</TD><TD>                this.init(port);</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="5">73</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">74</TD><TD> </TD></TR><TR><TD CLASS="l">75</TD><TD>        private void init(int port)</TD></TR><TR><TD CLASS="l">76</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">77</TD><TD>                this.globalID = new GlobalID(port);</TD></TR><TR CLASS="z"><TD CLASS="l">78</TD><TD>                this.init();</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="38">79</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">80</TD><TD>        </TD></TR><TR><TD CLASS="l">81</TD><TD>        private void init()</TD></TR><TR><TD CLASS="l">82</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">83</TD><TD>                this.access = new Semaphore(0, true);</TD></TR><TR CLASS="c"><TD CLASS="l">84</TD><TD>                this.modifyingCommands = new Semaphore(0, true);</TD></TR><TR CLASS="c"><TD CLASS="l">85</TD><TD>                if (this.globalID == null)</TD></TR><TR><TD CLASS="l">86</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">87</TD><TD>                        this.globalID = new GlobalID();</TD></TR><TR><TD CLASS="l">88</TD><TD>                }</TD></TR><TR><TD CLASS="l">89</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">90</TD><TD>                this.up = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">91</TD><TD>                this.down = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">92</TD><TD>                this.neighbours = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">93</TD><TD>                this.fold = this;</TD></TR><TR CLASS="c"><TD CLASS="l">94</TD><TD>                this.oldFold = null;</TD></TR><TR><TD CLASS="l">95</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">96</TD><TD>                this.state = EmptyState.getState();</TD></TR><TR><TD CLASS="l">97</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">98</TD><TD>                this.payload = new HashMap&lt;String, Object&gt;();</TD></TR><TR CLASS="c"><TD CLASS="l">99</TD><TD>                this.access = new Semaphore(0, true);</TD></TR><TR CLASS="c"><TD CLASS="l">100</TD><TD>                this.beingModified = false;</TD></TR><TR CLASS="c"><TD CLASS="l">101</TD><TD>                this.accessingData = 0;</TD></TR><TR><TD CLASS="l">102</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">103</TD><TD>        }</TD></TR><TR><TD CLASS="l">104</TD><TD>        </TD></TR><TR><TD CLASS="l">105</TD><TD>        /**</TD></TR><TR><TD CLASS="l">106</TD><TD>         * compares one Node to another</TD></TR><TR><TD CLASS="l">107</TD><TD>         * @param other - Node to compare to</TD></TR><TR><TD CLASS="l">108</TD><TD>         * @pre other != null</TD></TR><TR><TD CLASS="l">109</TD><TD>         * @post return -1 if this &lt; other | 0 if this == other | or 1 if this &gt; other         * </TD></TR><TR><TD CLASS="l"><A NAME="18">110</A></TD><TD>         *</TD></TR><TR><TD CLASS="l">111</TD><TD>         */</TD></TR><TR><TD CLASS="l">112</TD><TD>        public int compareTo(Node other)</TD></TR><TR><TD CLASS="l">113</TD><TD>        {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">114</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert other != null;</TD></TR><TR><TD CLASS="l">115</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">116</TD><TD>                boolean rootAccess = true;</TD></TR><TR><TD CLASS="l">117</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">118</TD><TD>                int result = 0;</TD></TR><TR><TD CLASS="l">119</TD><TD>                try</TD></TR><TR><TD CLASS="l">120</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">121</TD><TD>                        if (this.getId(true) &lt; other.getId(rootAccess))</TD></TR><TR><TD CLASS="l">122</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">123</TD><TD>                                result = -1;</TD></TR><TR><TD CLASS="l">124</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">125</TD><TD>                        else if (this.getId(true) &gt; other.getId(rootAccess))</TD></TR><TR><TD CLASS="l">126</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">127</TD><TD>                                result = 1;</TD></TR><TR><TD CLASS="l">128</TD><TD>                        }</TD></TR><TR><TD CLASS="l">129</TD><TD>                }</TD></TR><TR><TD CLASS="l">130</TD><TD>                //This exception should never be thrown with the parameter set to true</TD></TR><TR CLASS="z"><TD CLASS="l">131</TD><TD>                catch (InterruptedException e)</TD></TR><TR><TD CLASS="l">132</TD><TD>                {</TD></TR><TR><TD CLASS="l">133</TD><TD>                        ;</TD></TR><TR><TD CLASS="l">134</TD><TD>                }</TD></TR><TR><TD CLASS="l">135</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">136</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">137</TD><TD>        }</TD></TR><TR><TD CLASS="l">138</TD><TD>        </TD></TR><TR><TD CLASS="l">139</TD><TD>        /**</TD></TR><TR><TD CLASS="l">140</TD><TD>         * Gets the GlobalID</TD></TR><TR><TD CLASS="l">141</TD><TD>         * @return returns the GlobalID associated with this node</TD></TR><TR><TD CLASS="l">142</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="33">143</A></TD><TD>         * @post return the GlobalID</TD></TR><TR><TD CLASS="l">144</TD><TD>         */</TD></TR><TR><TD CLASS="l">145</TD><TD>        public GlobalID getGlobalID()</TD></TR><TR><TD CLASS="l">146</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">147</TD><TD>                return this.globalID;</TD></TR><TR><TD CLASS="l">148</TD><TD>        }</TD></TR><TR><TD CLASS="l">149</TD><TD>        </TD></TR><TR><TD CLASS="l">150</TD><TD>        /**</TD></TR><TR><TD CLASS="l">151</TD><TD>         * Returns the current NodeState that the node is in</TD></TR><TR><TD CLASS="l">152</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">153</TD><TD>         * @return The current state that the node is in</TD></TR><TR><TD CLASS="l">154</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="13">155</A></TD><TD>         * @post return current state</TD></TR><TR><TD CLASS="l">156</TD><TD>         */</TD></TR><TR><TD CLASS="l">157</TD><TD>        public NodeState getState(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">158</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">159</TD><TD>                while (!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">160</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">161</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">162</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">163</TD><TD>                return this.state;</TD></TR><TR><TD CLASS="l">164</TD><TD>        }</TD></TR><TR><TD CLASS="l">165</TD><TD>        </TD></TR><TR><TD CLASS="l">166</TD><TD>        /**</TD></TR><TR><TD CLASS="l">167</TD><TD>         * Sets the Node state as the parameter state</TD></TR><TR><TD CLASS="l">168</TD><TD>         * @param state New State the Node will be set to</TD></TR><TR><TD CLASS="l">169</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="17">170</A></TD><TD>         * @post this.state = state</TD></TR><TR><TD CLASS="l">171</TD><TD>         */</TD></TR><TR><TD CLASS="l">172</TD><TD>        public void setState(NodeState state) throws InterruptedException</TD></TR><TR><TD CLASS="l">173</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">174</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">175</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">176</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">177</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">178</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">179</TD><TD>                this.state = state;</TD></TR><TR CLASS="c"><TD CLASS="l">180</TD><TD>        }</TD></TR><TR><TD CLASS="l">181</TD><TD>        </TD></TR><TR><TD CLASS="l">182</TD><TD>        /**</TD></TR><TR><TD CLASS="l">183</TD><TD>         * Returns a NodeList of this node's upPointers</TD></TR><TR><TD CLASS="l">184</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">185</TD><TD>         * @return NodeList of upPointers</TD></TR><TR><TD CLASS="l">186</TD><TD>         * @throws InterruptedException </TD></TR><TR><TD CLASS="l">187</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="14">188</A></TD><TD>         * @post return the list of up pointers</TD></TR><TR><TD CLASS="l">189</TD><TD>         */</TD></TR><TR><TD CLASS="l">190</TD><TD>        public NodeList getUpPointers(boolean rootAccess) throws InterruptedException </TD></TR><TR><TD CLASS="l">191</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">192</TD><TD>                while (!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">193</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">194</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">195</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">196</TD><TD>                return this.up;</TD></TR><TR><TD CLASS="l">197</TD><TD>                </TD></TR><TR><TD CLASS="l">198</TD><TD>        }</TD></TR><TR><TD CLASS="l">199</TD><TD> </TD></TR><TR><TD CLASS="l">200</TD><TD>        /**</TD></TR><TR><TD CLASS="l">201</TD><TD>         * adds all the up pointers to the NodeList that is passed in</TD></TR><TR><TD CLASS="l">202</TD><TD>         * @param up - The NodeList of pointers that will be assigned</TD></TR><TR><TD CLASS="l">203</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="3">204</A></TD><TD>         * @post this.up = up</TD></TR><TR><TD CLASS="l">205</TD><TD>         */</TD></TR><TR><TD CLASS="l">206</TD><TD>        public void addUpPointers(NodeList up) throws InterruptedException</TD></TR><TR><TD CLASS="l">207</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">208</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="z"><TD CLASS="l">209</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">210</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">211</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">212</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">213</TD><TD>                this.up.addAll(up);</TD></TR><TR CLASS="z"><TD CLASS="l">214</TD><TD>        }</TD></TR><TR><TD CLASS="l">215</TD><TD>        </TD></TR><TR><TD CLASS="l">216</TD><TD>        /**</TD></TR><TR><TD CLASS="l">217</TD><TD>         * Sets all the up pointers to the NodeList that is passed in</TD></TR><TR><TD CLASS="l">218</TD><TD>         * @param up - The NodeList of pointers that will be assigned</TD></TR><TR><TD CLASS="l">219</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="20">220</A></TD><TD>         * @post this.up = up</TD></TR><TR><TD CLASS="l">221</TD><TD>         */</TD></TR><TR><TD CLASS="l">222</TD><TD>        public void setUpPointers(NodeList up) throws InterruptedException</TD></TR><TR><TD CLASS="l">223</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">224</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">225</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">226</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">227</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">228</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">229</TD><TD>                this.up = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">230</TD><TD>                this.up.addAll(up);</TD></TR><TR CLASS="c"><TD CLASS="l">231</TD><TD>        }</TD></TR><TR><TD CLASS="l">232</TD><TD>        </TD></TR><TR><TD CLASS="l">233</TD><TD>        /**</TD></TR><TR><TD CLASS="l">234</TD><TD>         * Adds an up pointer to the list</TD></TR><TR><TD CLASS="l">235</TD><TD>         * @param node</TD></TR><TR><TD CLASS="l">236</TD><TD>         * @pre node != null</TD></TR><TR><TD CLASS="l"><A NAME="c">237</A></TD><TD>         * @post node is added to the list of up pointers</TD></TR><TR><TD CLASS="l">238</TD><TD>         */</TD></TR><TR><TD CLASS="l">239</TD><TD>        public void setUpPointer(Node node) throws InterruptedException</TD></TR><TR><TD CLASS="l">240</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">241</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="45% line coverage (5 out of 11 instructions)">242</TD><TD TITLE="45% line coverage (5 out of 11 instructions)">                assert node != null;</TD></TR><TR CLASS="c"><TD CLASS="l">243</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">244</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">245</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">246</TD><TD>                }</TD></TR><TR><TD CLASS="l">247</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">248</TD><TD>                this.up.add(node);</TD></TR><TR CLASS="c"><TD CLASS="l">249</TD><TD>        }</TD></TR><TR><TD CLASS="l">250</TD><TD>        </TD></TR><TR><TD CLASS="l">251</TD><TD>        /**</TD></TR><TR><TD CLASS="l">252</TD><TD>         * returns the list of down pointers</TD></TR><TR><TD CLASS="l">253</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">254</TD><TD>         * @return return NodeList of down pointers</TD></TR><TR><TD CLASS="l">255</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="10">256</A></TD><TD>         * @post return list of down pointers</TD></TR><TR><TD CLASS="l">257</TD><TD>         */</TD></TR><TR><TD CLASS="l">258</TD><TD>        public NodeList getDownPointers(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">259</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">260</TD><TD>                while (!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">261</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">262</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">263</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">264</TD><TD>                return down;</TD></TR><TR><TD CLASS="l">265</TD><TD>        }        </TD></TR><TR><TD CLASS="l">266</TD><TD>        </TD></TR><TR><TD CLASS="l">267</TD><TD>        /**</TD></TR><TR><TD CLASS="l">268</TD><TD>         * adds the param down to the list of down pointers</TD></TR><TR><TD CLASS="l">269</TD><TD>         * @param down - list of nodes to set as down pointer list</TD></TR><TR><TD CLASS="l">270</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="2">271</A></TD><TD>         * @post this.down = down         * </TD></TR><TR><TD CLASS="l">272</TD><TD>         */</TD></TR><TR><TD CLASS="l">273</TD><TD>        public void addDownPointers(NodeList down) throws InterruptedException</TD></TR><TR><TD CLASS="l">274</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">275</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="z"><TD CLASS="l">276</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">277</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">278</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">279</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">280</TD><TD>                this.down.addAll(down);</TD></TR><TR CLASS="z"><TD CLASS="l">281</TD><TD>        }</TD></TR><TR><TD CLASS="l">282</TD><TD>        </TD></TR><TR><TD CLASS="l">283</TD><TD>        /**</TD></TR><TR><TD CLASS="l">284</TD><TD>         * sets the list of down pointers</TD></TR><TR><TD CLASS="l">285</TD><TD>         * @param down - list of nodes to set as down pointer list</TD></TR><TR><TD CLASS="l">286</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="1e">287</A></TD><TD>         * @post this.down = down         * </TD></TR><TR><TD CLASS="l">288</TD><TD>         */</TD></TR><TR><TD CLASS="l">289</TD><TD>        public void setDownPointers(NodeList down) throws InterruptedException</TD></TR><TR><TD CLASS="l">290</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">291</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">292</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">293</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">294</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">295</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">296</TD><TD>                this.down = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">297</TD><TD>                this.down.addAll(down);</TD></TR><TR CLASS="c"><TD CLASS="l">298</TD><TD>        }        </TD></TR><TR><TD CLASS="l">299</TD><TD>        /**</TD></TR><TR><TD CLASS="l">300</TD><TD>         * adds a node to the down pointers</TD></TR><TR><TD CLASS="l">301</TD><TD>         * @param down - node to add to list of down pointers</TD></TR><TR><TD CLASS="l">302</TD><TD>         * @pre down != null</TD></TR><TR><TD CLASS="l"><A NAME="b">303</A></TD><TD>         * @post down is added to the list of down pointers</TD></TR><TR><TD CLASS="l">304</TD><TD>         */</TD></TR><TR><TD CLASS="l">305</TD><TD>        public void setDownPointer(Node down) throws InterruptedException</TD></TR><TR><TD CLASS="l">306</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">307</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="45% line coverage (5 out of 11 instructions)">308</TD><TD TITLE="45% line coverage (5 out of 11 instructions)">                assert down != null;</TD></TR><TR CLASS="c"><TD CLASS="l">309</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">310</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">311</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">312</TD><TD>                }</TD></TR><TR><TD CLASS="l">313</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">314</TD><TD>                this.down.add(down);</TD></TR><TR CLASS="c"><TD CLASS="l">315</TD><TD>        }</TD></TR><TR><TD CLASS="l">316</TD><TD>        /**</TD></TR><TR><TD CLASS="l">317</TD><TD>         * gets the list of neighbours</TD></TR><TR><TD CLASS="l">318</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">319</TD><TD>         * @return list of neighbours</TD></TR><TR><TD CLASS="l">320</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="12">321</A></TD><TD>         * @post returns list of neighbours</TD></TR><TR><TD CLASS="l">322</TD><TD>         */</TD></TR><TR><TD CLASS="l">323</TD><TD>        public NodeList getNeighbours(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">324</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">325</TD><TD>                while (!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">326</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">327</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">328</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">329</TD><TD>                return neighbours;</TD></TR><TR><TD CLASS="l">330</TD><TD>        }</TD></TR><TR><TD CLASS="l">331</TD><TD>        </TD></TR><TR><TD CLASS="l">332</TD><TD>        /**</TD></TR><TR><TD CLASS="l">333</TD><TD>         * @param id - id of neighbour to get</TD></TR><TR><TD CLASS="l">334</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">335</TD><TD>         * @return node with specified id</TD></TR><TR><TD CLASS="l">336</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l">337</TD><TD>         * @post return node with specified id,</TD></TR><TR><TD CLASS="l">338</TD><TD>         * otherwise if not found return null</TD></TR><TR><TD CLASS="l"><A NAME="27">339</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">340</TD><TD>        public Node getNeighbour(int id, boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">341</TD><TD>        {</TD></TR><TR><TD CLASS="l">342</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">343</TD><TD>                while (!this.acquireAccessPriviledge(rootAccess))</TD></TR><TR><TD CLASS="l">344</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">345</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">346</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">347</TD><TD>                Node result = null;</TD></TR><TR CLASS="c"><TD CLASS="l">348</TD><TD>                NodeList neighbour = this.getNeighbours(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">349</TD><TD>                for(Node node : neighbour)</TD></TR><TR><TD CLASS="l">350</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">351</TD><TD>                        if(node.getId(rootAccess) == id)</TD></TR><TR><TD CLASS="l">352</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">353</TD><TD>                                result = node;</TD></TR><TR CLASS="c"><TD CLASS="l">354</TD><TD>                                break;</TD></TR><TR><TD CLASS="l">355</TD><TD>                        }</TD></TR><TR><TD CLASS="l">356</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">357</TD><TD>                this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">358</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">359</TD><TD>        }</TD></TR><TR><TD CLASS="l">360</TD><TD>        </TD></TR><TR><TD CLASS="l">361</TD><TD>        /**</TD></TR><TR><TD CLASS="l">362</TD><TD>         * adds the parameter neighbours to this node's neighbours</TD></TR><TR><TD CLASS="l">363</TD><TD>         * @param neighbours</TD></TR><TR><TD CLASS="l">364</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l">365</TD><TD>         * @post this.neighbours = neighbours</TD></TR><TR><TD CLASS="l"><A NAME="19">366</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">367</TD><TD>        </TD></TR><TR><TD CLASS="l">368</TD><TD>        public void addNeighbours(NodeList neighbours) throws InterruptedException</TD></TR><TR><TD CLASS="l">369</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">370</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">371</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">372</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">373</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">374</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">375</TD><TD>                this.neighbours.addAll(neighbours);</TD></TR><TR CLASS="c"><TD CLASS="l">376</TD><TD>        }</TD></TR><TR><TD CLASS="l">377</TD><TD>        </TD></TR><TR><TD CLASS="l">378</TD><TD>        /**</TD></TR><TR><TD CLASS="l">379</TD><TD>         * sets the neighbours for this node</TD></TR><TR><TD CLASS="l">380</TD><TD>         * @param neighbours</TD></TR><TR><TD CLASS="l">381</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="1f">382</A></TD><TD>         * @post this.neighbours = neighbours</TD></TR><TR><TD CLASS="l">383</TD><TD>         */</TD></TR><TR><TD CLASS="l">384</TD><TD>        public void setNeighbours(NodeList neighbours) throws InterruptedException</TD></TR><TR><TD CLASS="l">385</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">386</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">387</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">388</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">389</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">390</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">391</TD><TD>                this.neighbours = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">392</TD><TD>                this.neighbours.addAll(neighbours);</TD></TR><TR CLASS="c"><TD CLASS="l">393</TD><TD>        }</TD></TR><TR><TD CLASS="l">394</TD><TD>        </TD></TR><TR><TD CLASS="l">395</TD><TD>        /**</TD></TR><TR><TD CLASS="l">396</TD><TD>         * adds a neighbour</TD></TR><TR><TD CLASS="l">397</TD><TD>         * @param neighbour - neighbour to be added</TD></TR><TR><TD CLASS="l">398</TD><TD>         * @pre neighbour != null</TD></TR><TR><TD CLASS="l"><A NAME="d">399</A></TD><TD>         * @post neighbour added to list of neighbours</TD></TR><TR><TD CLASS="l">400</TD><TD>         */</TD></TR><TR><TD CLASS="l">401</TD><TD>        public void addNeighbour(Node neighbour) throws InterruptedException</TD></TR><TR><TD CLASS="l">402</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">403</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">404</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">405</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">406</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">407</TD><TD>                }</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">408</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert neighbour != null;</TD></TR><TR><TD CLASS="l">409</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">410</TD><TD>                this.neighbours.add(neighbour);</TD></TR><TR CLASS="c"><TD CLASS="l">411</TD><TD>        }</TD></TR><TR><TD CLASS="l">412</TD><TD>        </TD></TR><TR><TD CLASS="l">413</TD><TD>        /**</TD></TR><TR><TD CLASS="l">414</TD><TD>         * gets the current fold</TD></TR><TR><TD CLASS="l">415</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">416</TD><TD>         * @return the current fold</TD></TR><TR><TD CLASS="l">417</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="11">418</A></TD><TD>         * @post returns the current fold</TD></TR><TR><TD CLASS="l">419</TD><TD>         */</TD></TR><TR><TD CLASS="l">420</TD><TD>        public Node getFold(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">421</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">422</TD><TD>                while (!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">423</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">424</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">425</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">426</TD><TD>                return fold;</TD></TR><TR><TD CLASS="l">427</TD><TD>        }</TD></TR><TR><TD CLASS="l">428</TD><TD>        </TD></TR><TR><TD CLASS="l">429</TD><TD>        /**</TD></TR><TR><TD CLASS="l">430</TD><TD>         * sets the fold</TD></TR><TR><TD CLASS="l">431</TD><TD>         * @param fold - fold to be set</TD></TR><TR><TD CLASS="l">432</TD><TD>         * @pre fold != null</TD></TR><TR><TD CLASS="l"><A NAME="9">433</A></TD><TD>         * @post this.fold = fold</TD></TR><TR><TD CLASS="l">434</TD><TD>         */</TD></TR><TR><TD CLASS="l">435</TD><TD>        public void setFold(Node fold) throws InterruptedException</TD></TR><TR><TD CLASS="l">436</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">437</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="45% line coverage (5 out of 11 instructions)">438</TD><TD TITLE="45% line coverage (5 out of 11 instructions)">                assert fold != null;</TD></TR><TR CLASS="c"><TD CLASS="l">439</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">440</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">441</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">442</TD><TD>                }</TD></TR><TR><TD CLASS="l">443</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">444</TD><TD>                this.fold = fold;</TD></TR><TR CLASS="c"><TD CLASS="l">445</TD><TD>        }</TD></TR><TR><TD CLASS="l">446</TD><TD>        </TD></TR><TR><TD CLASS="l">447</TD><TD>        /**</TD></TR><TR><TD CLASS="l">448</TD><TD>         * gets the old fold</TD></TR><TR><TD CLASS="l">449</TD><TD>         * @return the old fold</TD></TR><TR><TD CLASS="l">450</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="35">451</A></TD><TD>         * @post returns the old fold</TD></TR><TR><TD CLASS="l">452</TD><TD>         */</TD></TR><TR><TD CLASS="l">453</TD><TD>        public Node getOldFold() </TD></TR><TR><TD CLASS="l">454</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">455</TD><TD>                return oldFold;</TD></TR><TR><TD CLASS="l">456</TD><TD>        }</TD></TR><TR><TD CLASS="l">457</TD><TD>        /**</TD></TR><TR><TD CLASS="l">458</TD><TD>         * sets the old fold</TD></TR><TR><TD CLASS="l">459</TD><TD>         * @param oldFold - fold to be set</TD></TR><TR><TD CLASS="l">460</TD><TD>         * @pre fold != null</TD></TR><TR><TD CLASS="l"><A NAME="8">461</A></TD><TD>         * @post this.oldFold = oldFold</TD></TR><TR><TD CLASS="l">462</TD><TD>         */        </TD></TR><TR><TD CLASS="l">463</TD><TD>        public void setOldFold(Node oldFold) throws InterruptedException</TD></TR><TR><TD CLASS="l">464</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">465</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="42% line coverage (5 out of 12 instructions)">466</TD><TD TITLE="42% line coverage (5 out of 12 instructions)">                assert fold != null;</TD></TR><TR CLASS="c"><TD CLASS="l">467</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">468</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">469</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">470</TD><TD>                }</TD></TR><TR><TD CLASS="l">471</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">472</TD><TD>                this.oldFold = oldFold;</TD></TR><TR CLASS="c"><TD CLASS="l">473</TD><TD>        }</TD></TR><TR><TD CLASS="l">474</TD><TD>        </TD></TR><TR><TD CLASS="l">475</TD><TD>        /**</TD></TR><TR><TD CLASS="l">476</TD><TD>         * returns the id of the node</TD></TR><TR><TD CLASS="l">477</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">478</TD><TD>         * @return the id of the node</TD></TR><TR><TD CLASS="l">479</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l">480</TD><TD>         * @post return id of node</TD></TR><TR><TD CLASS="l">481</TD><TD>         */</TD></TR><TR><TD CLASS="l">482</TD><TD>        public int getId(boolean rootAccess) throws InterruptedException </TD></TR><TR><TD CLASS="l">483</TD><TD>        {</TD></TR><TR><TD CLASS="l"><A NAME="34">484</A></TD><TD>                /*while(!rootAccess &amp;&amp; beingModified)</TD></TR><TR><TD CLASS="l">485</TD><TD>                {</TD></TR><TR><TD CLASS="l">486</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">487</TD><TD>                }*/</TD></TR><TR CLASS="c"><TD CLASS="l">488</TD><TD>                return id;</TD></TR><TR><TD CLASS="l">489</TD><TD>        }</TD></TR><TR><TD CLASS="l">490</TD><TD>        </TD></TR><TR><TD CLASS="l">491</TD><TD>        /**</TD></TR><TR><TD CLASS="l">492</TD><TD>         * sets the id of the node</TD></TR><TR><TD CLASS="l">493</TD><TD>         * @param id - id to be set</TD></TR><TR><TD CLASS="l">494</TD><TD>         * @pre 0 &lt;= id &lt; 2^(height + 1) if in Empty State or Last State or 0 &lt;= id &lt; 2^height otherwise. (id is then valid)</TD></TR><TR><TD CLASS="l"><A NAME="16">495</A></TD><TD>         * @post this.id = id</TD></TR><TR><TD CLASS="l">496</TD><TD>         */</TD></TR><TR><TD CLASS="l">497</TD><TD>        public void setId(int id) throws InterruptedException</TD></TR><TR><TD CLASS="l">498</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">499</TD><TD>                Assert.assertTrue(beingModified);</TD></TR><TR CLASS="c"><TD CLASS="l">500</TD><TD>                while (this.accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">501</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">502</TD><TD>                        modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">503</TD><TD>                }</TD></TR><TR><TD CLASS="l">504</TD><TD>/*                if(this.getState() instanceof EmptyState || this.getState() instanceof LastState)</TD></TR><TR><TD CLASS="l">505</TD><TD>                {</TD></TR><TR><TD CLASS="l">506</TD><TD>                        assert id &lt; Math.pow(2, this.getHeight() + 1) &amp;&amp; id &gt;= 0;</TD></TR><TR><TD CLASS="l">507</TD><TD> </TD></TR><TR><TD CLASS="l">508</TD><TD>                }</TD></TR><TR><TD CLASS="l">509</TD><TD>                else</TD></TR><TR><TD CLASS="l">510</TD><TD>                {</TD></TR><TR><TD CLASS="l">511</TD><TD>                        assert id &lt; Math.pow(2, this.getHeight()) &amp;&amp; id &gt;= 0;</TD></TR><TR><TD CLASS="l">512</TD><TD>                }*/</TD></TR><TR CLASS="c"><TD CLASS="l">513</TD><TD>                this.id = id;</TD></TR><TR CLASS="c"><TD CLASS="l">514</TD><TD>        }</TD></TR><TR><TD CLASS="l">515</TD><TD>        </TD></TR><TR><TD CLASS="l">516</TD><TD>        /**</TD></TR><TR><TD CLASS="l">517</TD><TD>         * return the height of the node</TD></TR><TR><TD CLASS="l">518</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">519</TD><TD>         * @return the height of the node</TD></TR><TR><TD CLASS="l">520</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l"><A NAME="23">521</A></TD><TD>         * @post returns the height of the node</TD></TR><TR><TD CLASS="l">522</TD><TD>         */</TD></TR><TR><TD CLASS="l">523</TD><TD>        public int getHeight(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">524</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">525</TD><TD>                while (!this.acquireAccessPriviledge(rootAccess))</TD></TR><TR><TD CLASS="l">526</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">527</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">528</TD><TD>                }</TD></TR><TR><TD CLASS="l">529</TD><TD>                int result;</TD></TR><TR CLASS="c"><TD CLASS="l">530</TD><TD>                if(this.down.size() &gt; 0)</TD></TR><TR><TD CLASS="l">531</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">532</TD><TD>                        result = this.down.size() + this.neighbours.size();</TD></TR><TR><TD CLASS="l">533</TD><TD>                }</TD></TR><TR><TD CLASS="l">534</TD><TD>                else</TD></TR><TR><TD CLASS="l">535</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">536</TD><TD>                        result = this.neighbours.size();</TD></TR><TR><TD CLASS="l">537</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">538</TD><TD>                this.releaseAccessPriviledge();</TD></TR><TR><TD CLASS="l">539</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">540</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">541</TD><TD>                </TD></TR><TR><TD CLASS="l">542</TD><TD>        }</TD></TR><TR><TD CLASS="l">543</TD><TD>        </TD></TR><TR><TD CLASS="l">544</TD><TD>        /**</TD></TR><TR><TD CLASS="l">545</TD><TD>         * returns the parent of the node</TD></TR><TR><TD CLASS="l">546</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">547</TD><TD>         * @return parent of the node</TD></TR><TR><TD CLASS="l">548</TD><TD>         * @pre This Node has a parent</TD></TR><TR><TD CLASS="l">549</TD><TD>         * @post return node with id half of this node(always rounding down)</TD></TR><TR><TD CLASS="l">550</TD><TD>         */</TD></TR><TR><TD CLASS="l"><A NAME="1a">551</A></TD><TD>        public Node getParent(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">552</TD><TD>        {</TD></TR><TR><TD CLASS="l">553</TD><TD>                //assert this.getState(rootAccess).toString().compareTo(&#34;EmptyState&#34;) != 0;</TD></TR><TR><TD CLASS="l">554</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">555</TD><TD>                if(!this.acquireAccessPriviledge(rootAccess))</TD></TR><TR><TD CLASS="l">556</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">557</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">558</TD><TD>                }</TD></TR><TR><TD CLASS="l">559</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">560</TD><TD>                int possibleParent = this.getId(rootAccess) ^ (int) (Math.pow(2, getHeight(rootAccess) - 1));</TD></TR><TR CLASS="c"><TD CLASS="l">561</TD><TD>                if(possibleParent &lt; this.id)</TD></TR><TR><TD CLASS="l">562</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">563</TD><TD>                        Node neighbour = this.getNeighbour(possibleParent, rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">564</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">565</TD><TD>                        return neighbour;</TD></TR><TR><TD CLASS="l">566</TD><TD>                }</TD></TR><TR><TD CLASS="l">567</TD><TD>                else</TD></TR><TR><TD CLASS="l">568</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">569</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="z"><TD CLASS="l">570</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">571</TD><TD>                }                </TD></TR><TR><TD CLASS="l">572</TD><TD>        }</TD></TR><TR><TD CLASS="l">573</TD><TD>        </TD></TR><TR><TD CLASS="l">574</TD><TD> </TD></TR><TR><TD CLASS="l">575</TD><TD>        /**</TD></TR><TR><TD CLASS="l">576</TD><TD>         * Gets the child of the node</TD></TR><TR><TD CLASS="l">577</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">578</TD><TD>         * @return child of node</TD></TR><TR><TD CLASS="l">579</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="1c">580</A></TD><TD>         * @post return the child node or null if there is no child</TD></TR><TR><TD CLASS="l">581</TD><TD>         */</TD></TR><TR><TD CLASS="l">582</TD><TD>        public Node getChild(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">583</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">584</TD><TD>                boolean allSatisfied = false;</TD></TR><TR CLASS="c"><TD CLASS="l">585</TD><TD>                Node child = null;</TD></TR><TR CLASS="c"><TD CLASS="l">586</TD><TD>                while (!allSatisfied)</TD></TR><TR><TD CLASS="l">587</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">588</TD><TD>                        boolean[] satisfied = new boolean[2];</TD></TR><TR CLASS="c"><TD CLASS="l">589</TD><TD>                        satisfied[0] = this.acquireAccessPriviledge(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">590</TD><TD>                        allSatisfied = satisfied[0];</TD></TR><TR CLASS="c"><TD CLASS="l">591</TD><TD>                        if(allSatisfied)</TD></TR><TR><TD CLASS="l">592</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">593</TD><TD>                                child = neighbours.getMax();</TD></TR><TR CLASS="c"><TD CLASS="l">594</TD><TD>                                satisfied[1] = child.acquireAccessPriviledge(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">595</TD><TD>                                allSatisfied = satisfied[1];</TD></TR><TR><TD CLASS="l">596</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">597</TD><TD>                        if(!allSatisfied)</TD></TR><TR><TD CLASS="l">598</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">599</TD><TD>                                if(satisfied[0])</TD></TR><TR><TD CLASS="l">600</TD><TD>                                {</TD></TR><TR CLASS="z"><TD CLASS="l">601</TD><TD>                                        this.releaseAccessPriviledge();</TD></TR><TR><TD CLASS="l">602</TD><TD>                                }</TD></TR><TR CLASS="z"><TD CLASS="l">603</TD><TD>                                if(satisfied[1])</TD></TR><TR><TD CLASS="l">604</TD><TD>                                {</TD></TR><TR CLASS="z"><TD CLASS="l">605</TD><TD>                                        child.releaseAccessPriviledge();</TD></TR><TR><TD CLASS="l">606</TD><TD>                                }</TD></TR><TR CLASS="z"><TD CLASS="l">607</TD><TD>                                access.acquire();</TD></TR><TR><TD CLASS="l">608</TD><TD>                        }</TD></TR><TR><TD CLASS="l">609</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">610</TD><TD>                if(neighbours.getMax() != null</TD></TR><TR CLASS="c"><TD CLASS="l">611</TD><TD>                                &amp;&amp; child.getId(rootAccess) == (this.getId(rootAccess) + (int) (Math.pow(2, this.getHeight(rootAccess) - 1)))</TD></TR><TR CLASS="c"><TD CLASS="l">612</TD><TD>                                &amp;&amp; child.getState(rootAccess) instanceof DownState)</TD></TR><TR><TD CLASS="l">613</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">614</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">615</TD><TD>                        child.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">616</TD><TD>                        return child;</TD></TR><TR><TD CLASS="l">617</TD><TD>                }</TD></TR><TR><TD CLASS="l">618</TD><TD>                else</TD></TR><TR><TD CLASS="l">619</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">620</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">621</TD><TD>                        child.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">622</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">623</TD><TD>                }</TD></TR><TR><TD CLASS="l">624</TD><TD>        }</TD></TR><TR><TD CLASS="l">625</TD><TD>        /**</TD></TR><TR><TD CLASS="l">626</TD><TD>         * Returns the Node that logically would be the child without checking the Node state to see if it actually is a Child</TD></TR><TR><TD CLASS="l">627</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">628</TD><TD>         * @return The Node whose Id would be child or null if that Node does not exist</TD></TR><TR><TD CLASS="l">629</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="28">630</A></TD><TD>         * @post Return the Node whose Id == the id of the theoretical child or null if that Node does not exist</TD></TR><TR><TD CLASS="l">631</TD><TD>         */</TD></TR><TR><TD CLASS="l">632</TD><TD>        public Node giveMeChild(boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">633</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">634</TD><TD>                if(!this.acquireAccessPriviledge(rootAccess))</TD></TR><TR><TD CLASS="l">635</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">636</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">637</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">638</TD><TD>                Node child = this.getNeighbours(rootAccess).getMax();</TD></TR><TR CLASS="c"><TD CLASS="l">639</TD><TD>                if(child != null &amp;&amp; child.getId(rootAccess) == (this.getId(rootAccess) + (int) (Math.pow(2, this.getHeight(rootAccess) - 1)))</TD></TR><TR><TD CLASS="l">640</TD><TD>                )</TD></TR><TR><TD CLASS="l">641</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">642</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">643</TD><TD>                        return child;</TD></TR><TR><TD CLASS="l">644</TD><TD>                }</TD></TR><TR><TD CLASS="l">645</TD><TD>                else</TD></TR><TR><TD CLASS="l">646</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">647</TD><TD>                        this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">648</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">649</TD><TD>                }</TD></TR><TR><TD CLASS="l">650</TD><TD>        }</TD></TR><TR><TD CLASS="l">651</TD><TD>        </TD></TR><TR><TD CLASS="l">652</TD><TD>        /**</TD></TR><TR><TD CLASS="l">653</TD><TD>         * Returns the value associated with the string key</TD></TR><TR><TD CLASS="l">654</TD><TD>         * @param id - key value for the object you are retrieving from the node's payload</TD></TR><TR><TD CLASS="l">655</TD><TD>         * @return the value pair in payload associated with the key-id</TD></TR><TR><TD CLASS="l">656</TD><TD>         * @pre id is a non-null string</TD></TR><TR><TD CLASS="l"><A NAME="36">657</A></TD><TD>         * @post return null or the object associated with the key-id</TD></TR><TR><TD CLASS="l">658</TD><TD>         */</TD></TR><TR><TD CLASS="l">659</TD><TD>        public Object getPayload(String id)</TD></TR><TR><TD CLASS="l">660</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">661</TD><TD>                return this.payload.get(id);</TD></TR><TR><TD CLASS="l">662</TD><TD>        }</TD></TR><TR><TD CLASS="l">663</TD><TD>        </TD></TR><TR><TD CLASS="l">664</TD><TD>        /**</TD></TR><TR><TD CLASS="l">665</TD><TD>         * Sets a payload in the node with a key value</TD></TR><TR><TD CLASS="l">666</TD><TD>         * @param id - key object</TD></TR><TR><TD CLASS="l">667</TD><TD>         * @param obj - value object</TD></TR><TR><TD CLASS="l">668</TD><TD>         * @return the previous mapping to the key-id or null if it was not their already</TD></TR><TR><TD CLASS="l">669</TD><TD>         * @pre id != null &amp;&amp; obj != null</TD></TR><TR><TD CLASS="l"><A NAME="3e">670</A></TD><TD>         * @post return null if no previous mapping to id, otherwise return the previous valued mapped to id</TD></TR><TR><TD CLASS="l">671</TD><TD>         */</TD></TR><TR><TD CLASS="l">672</TD><TD>        public Object setPayload(String id, Object obj)</TD></TR><TR><TD CLASS="l">673</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">674</TD><TD>                return this.payload.put(id, obj);</TD></TR><TR><TD CLASS="l">675</TD><TD>        }</TD></TR><TR><TD CLASS="l">676</TD><TD>        </TD></TR><TR><TD CLASS="l">677</TD><TD>        /**</TD></TR><TR><TD CLASS="l">678</TD><TD>         * Returns the entire payload of the node as a Map</TD></TR><TR><TD CLASS="l">679</TD><TD>         * @return a Map which contains the whole payload of this node</TD></TR><TR><TD CLASS="l">680</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="37">681</A></TD><TD>         * @post return the payload associated with this node</TD></TR><TR><TD CLASS="l">682</TD><TD>         */</TD></TR><TR><TD CLASS="l">683</TD><TD>        public Map&lt;String, Object&gt; getWholePayload()</TD></TR><TR><TD CLASS="l">684</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">685</TD><TD>                return this.payload;</TD></TR><TR><TD CLASS="l">686</TD><TD>        }</TD></TR><TR><TD CLASS="l">687</TD><TD>        </TD></TR><TR><TD CLASS="l">688</TD><TD>        /**</TD></TR><TR><TD CLASS="l">689</TD><TD>         * Assigns payload to this node's payload</TD></TR><TR><TD CLASS="l">690</TD><TD>         * @param payload - the Map to be assigned to this payload</TD></TR><TR><TD CLASS="l">691</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="6">692</A></TD><TD>         * @post this.payload = payload</TD></TR><TR><TD CLASS="l">693</TD><TD>         */</TD></TR><TR><TD CLASS="l">694</TD><TD>        public void setWholePayload(Map&lt;String, Object&gt; payload)</TD></TR><TR><TD CLASS="l">695</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">696</TD><TD>                this.payload = payload;</TD></TR><TR CLASS="z"><TD CLASS="l">697</TD><TD>        }</TD></TR><TR><TD CLASS="l">698</TD><TD>        </TD></TR><TR><TD CLASS="l">699</TD><TD>        /**</TD></TR><TR><TD CLASS="l">700</TD><TD>         * Method to accept a visitor command</TD></TR><TR><TD CLASS="l">701</TD><TD>         * @param v - the visitor to call visit upon</TD></TR><TR><TD CLASS="l">702</TD><TD>         * @param i - the information this visitor needs to function</TD></TR><TR><TD CLASS="l">703</TD><TD>         * @throws InterruptedException</TD></TR><TR><TD CLASS="l">704</TD><TD>         * @pre v != null</TD></TR><TR><TD CLASS="l"><A NAME="30">705</A></TD><TD>         * @post the visitor v, visits this node</TD></TR><TR><TD CLASS="l">706</TD><TD>         */</TD></TR><TR><TD CLASS="l">707</TD><TD>        public void accept(Visitor v, Object i) throws InterruptedException</TD></TR><TR><TD CLASS="l">708</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">709</TD><TD>                v.visit(this, i);</TD></TR><TR CLASS="c"><TD CLASS="l">710</TD><TD>        }</TD></TR><TR><TD CLASS="l">711</TD><TD>        </TD></TR><TR><TD CLASS="l">712</TD><TD>        /**</TD></TR><TR><TD CLASS="l">713</TD><TD>         * Method to accept a visitor command with a response</TD></TR><TR><TD CLASS="l">714</TD><TD>         * @param v - the visitor to call visit upon</TD></TR><TR><TD CLASS="l">715</TD><TD>         * @param i - the information this visitor needs to function</TD></TR><TR><TD CLASS="l">716</TD><TD>         * @return the results of v's visit to this node</TD></TR><TR><TD CLASS="l">717</TD><TD>         * @throws InterruptedException</TD></TR><TR><TD CLASS="l">718</TD><TD>         * @pre v != null</TD></TR><TR><TD CLASS="l"><A NAME="31">719</A></TD><TD>         * @post the visitor v, visits this nod, and returns the result of the visit</TD></TR><TR><TD CLASS="l">720</TD><TD>         */</TD></TR><TR><TD CLASS="l">721</TD><TD>        public Object acceptWithResponse(Visitor v, Object i) throws InterruptedException</TD></TR><TR><TD CLASS="l">722</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">723</TD><TD>                return v.visit(this, i);</TD></TR><TR><TD CLASS="l">724</TD><TD>        }</TD></TR><TR><TD CLASS="l">725</TD><TD> </TD></TR><TR><TD CLASS="l">726</TD><TD>        /**</TD></TR><TR><TD CLASS="l">727</TD><TD>         * returns the range or node to &#34;right&#34; of node</TD></TR><TR><TD CLASS="l">728</TD><TD>         * @param callingNode - node to find it's &#34;right&#34; neighbour</TD></TR><TR><TD CLASS="l">729</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">730</TD><TD>         * @return the range or node to &#34;right&#34; of node</TD></TR><TR><TD CLASS="l">731</TD><TD>         * @pre callingNode != null</TD></TR><TR><TD CLASS="l"><A NAME="e">732</A></TD><TD>         * @post return the range or node to &#34;right&#34; of node</TD></TR><TR><TD CLASS="l">733</TD><TD>         */</TD></TR><TR><TD CLASS="l">734</TD><TD>        public NodeOrRange goRight(Node callingNode, boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">735</TD><TD>        {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">736</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert callingNode != null;</TD></TR><TR><TD CLASS="l">737</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">738</TD><TD>                while (!state.lockState(callingNode, rootAccess))</TD></TR><TR><TD CLASS="l">739</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">740</TD><TD>                        access.acquire();</TD></TR><TR><TD CLASS="l">741</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">742</TD><TD>                NodeOrRange result = state.goRight(callingNode, rootAccess);</TD></TR><TR><TD CLASS="l">743</TD><TD>                //this.releaseAccessPriviledge();</TD></TR><TR CLASS="c"><TD CLASS="l">744</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">745</TD><TD>        }</TD></TR><TR><TD CLASS="l">746</TD><TD>        </TD></TR><TR><TD CLASS="l">747</TD><TD>        /**</TD></TR><TR><TD CLASS="l">748</TD><TD>         * Returns the Node where the insertion Node should be inserted</TD></TR><TR><TD CLASS="l">749</TD><TD>         * @return the insertion point in the hypeer web</TD></TR><TR><TD CLASS="l">750</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l">751</TD><TD>         * @post returns Node that is the insertion point for a new Node</TD></TR><TR><TD CLASS="l"><A NAME="25">752</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">753</TD><TD>        </TD></TR><TR><TD CLASS="l">754</TD><TD>        public Node getInsertionPoint() throws InterruptedException</TD></TR><TR><TD CLASS="l">755</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">756</TD><TD>                boolean rootAccess = false;</TD></TR><TR><TD CLASS="l">757</TD><TD>                try</TD></TR><TR><TD CLASS="l">758</TD><TD>                {</TD></TR><TR><TD CLASS="l">759</TD><TD>                        NodeOrRange node;</TD></TR><TR CLASS="c"><TD CLASS="l">760</TD><TD>                        node = goRight(this, rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">761</TD><TD>                        if(node == null &amp;&amp; this.id == 0)</TD></TR><TR><TD CLASS="l">762</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">763</TD><TD>                                this.setPayload(&#34;busy&#34;, new Semaphore(0, true));</TD></TR><TR><TD CLASS="l">764</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">765</TD><TD>                                return this;</TD></TR><TR><TD CLASS="l">766</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">767</TD><TD>                        while (node instanceof Node)</TD></TR><TR><TD CLASS="l">768</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">769</TD><TD>                                node = ((Node) node).goRight((Node) node, rootAccess);</TD></TR><TR><TD CLASS="l">770</TD><TD>                        }</TD></TR><TR><TD CLASS="l">771</TD><TD>                        //System.out.println(&#34;Range now found.&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">772</TD><TD>                        InsertionRange range = (InsertionRange) node;</TD></TR><TR><TD CLASS="l">773</TD><TD>                        Node midrange;</TD></TR><TR><TD CLASS="l">774</TD><TD>                        //all return values to goRight(..) will now be a Range</TD></TR><TR CLASS="c"><TD CLASS="l">775</TD><TD>                        while (range.getLowerBound() != range.getUpperBound().getId(rootAccess))</TD></TR><TR><TD CLASS="l">776</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">777</TD><TD>                                int mid = Math.round((range.getLowerBound() + range.getUpperBound().getId(rootAccess)) / 2);</TD></TR><TR CLASS="c"><TD CLASS="l">778</TD><TD>                                midrange = find(mid, range.getUpperBound(), rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">779</TD><TD>                                if(midrange.getChild(rootAccess) != null)</TD></TR><TR><TD CLASS="l">780</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">781</TD><TD>                                        range.setLowerBound(midrange.getId(rootAccess) + 1);                                </TD></TR><TR><TD CLASS="l">782</TD><TD>                                }</TD></TR><TR><TD CLASS="l">783</TD><TD>                                else</TD></TR><TR><TD CLASS="l">784</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">785</TD><TD>                                        range.setUpperBound(midrange);</TD></TR><TR><TD CLASS="l">786</TD><TD>                                }</TD></TR><TR><TD CLASS="l">787</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">788</TD><TD>                        Node insertionPoint = range.getUpperBound();</TD></TR><TR><TD CLASS="l">789</TD><TD>                        </TD></TR><TR CLASS="c"><TD CLASS="l">790</TD><TD>                        if(insertionPoint.getInsertionLock())</TD></TR><TR><TD CLASS="l">791</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">792</TD><TD>                                return insertionPoint;</TD></TR><TR><TD CLASS="l">793</TD><TD>                        }</TD></TR><TR><TD CLASS="l">794</TD><TD>                        else</TD></TR><TR><TD CLASS="l">795</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">796</TD><TD>                                return null;</TD></TR><TR><TD CLASS="l">797</TD><TD>                        }</TD></TR><TR><TD CLASS="l">798</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">799</TD><TD>                catch (IllegalStateException e)</TD></TR><TR><TD CLASS="l">800</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">801</TD><TD>                        throw new NullPointerException(&#34;Error finding Insertion Point.&#34;);</TD></TR><TR><TD CLASS="l">802</TD><TD>                }</TD></TR><TR><TD CLASS="l">803</TD><TD>        }</TD></TR><TR><TD CLASS="l">804</TD><TD>        </TD></TR><TR><TD CLASS="l">805</TD><TD>        /**</TD></TR><TR><TD CLASS="l">806</TD><TD>         * Traverses the HypeerWeb starting at nextNode until it finds a node whose getId() == id</TD></TR><TR><TD CLASS="l">807</TD><TD>         * @param id An integer representing the Node ID that is being searched for</TD></TR><TR><TD CLASS="l">808</TD><TD>         * @param nextNode The Node in the Hypeer Web where the search for the parameter id starts</TD></TR><TR><TD CLASS="l">809</TD><TD>         * @param rootAccess - boolean whether you are trying to modify the node</TD></TR><TR><TD CLASS="l">810</TD><TD>         * @return the Node in the Hypeer Web whose getId() == id</TD></TR><TR><TD CLASS="l">811</TD><TD>         * @pre nextNode != null &amp;&amp; id &gt;= 0</TD></TR><TR><TD CLASS="l">812</TD><TD>         * @post return Node whose getId() == id if such a node exists in the hypeer web</TD></TR><TR><TD CLASS="l"><A NAME="24">813</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">814</TD><TD>        </TD></TR><TR><TD CLASS="l">815</TD><TD>        public static Node find(int id, Node nextNode, boolean rootAccess) throws InterruptedException</TD></TR><TR><TD CLASS="l">816</TD><TD>        {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="20% line coverage (2 out of 10 instructions)">817</TD><TD TITLE="20% line coverage (2 out of 10 instructions)">                assert nextNode != null &amp;&amp; id &gt;= 0;</TD></TR><TR><TD CLASS="l">818</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">819</TD><TD>                Node answer = nextNode;</TD></TR><TR CLASS="c"><TD CLASS="l">820</TD><TD>                Iterator&lt;Node&gt; iter = nextNode.getNeighbours(rootAccess).iterator();</TD></TR><TR CLASS="c"><TD CLASS="l">821</TD><TD>                for(; iter.hasNext() &amp;&amp; answer.getId(rootAccess) != id;)</TD></TR><TR><TD CLASS="l">822</TD><TD>                {</TD></TR><TR><TD CLASS="l">823</TD><TD>                        //Node height and number of neighbors are the same so no indexing problems here</TD></TR><TR CLASS="c"><TD CLASS="l">824</TD><TD>                        Node neighbour = iter.next();</TD></TR><TR CLASS="c"><TD CLASS="l">825</TD><TD>                        int targetBit = neighbour.getId(rootAccess) ^ nextNode.getId(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">826</TD><TD>                        if(neighbour.getId(rootAccess) == id)</TD></TR><TR><TD CLASS="l">827</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">828</TD><TD>                                return neighbour;</TD></TR><TR><TD CLASS="l">829</TD><TD>                        }</TD></TR><TR><TD CLASS="l">830</TD><TD>                        //Checks to see if this neighbour is one closer to the target id</TD></TR><TR CLASS="c"><TD CLASS="l">831</TD><TD>                        else if(neighbour.getId(rootAccess) != id &amp;&amp; ((neighbour.getId(rootAccess) &amp; targetBit) == (id &amp; targetBit)))</TD></TR><TR><TD CLASS="l">832</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">833</TD><TD>                                answer = find(id, neighbour, rootAccess);</TD></TR><TR><TD CLASS="l">834</TD><TD>                        }</TD></TR><TR><TD CLASS="l">835</TD><TD>                        //Neighbour being searched for that was potentially one closer to the target node, was not found</TD></TR><TR CLASS="c"><TD CLASS="l">836</TD><TD>                        if (answer == null)</TD></TR><TR><TD CLASS="l">837</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">838</TD><TD>                                answer = nextNode;</TD></TR><TR><TD CLASS="l">839</TD><TD>                        }</TD></TR><TR><TD CLASS="l">840</TD><TD>                }</TD></TR><TR><TD CLASS="l">841</TD><TD>                // added null conditional if the node is not found</TD></TR><TR CLASS="c"><TD CLASS="l">842</TD><TD>                if(answer != null &amp;&amp; answer.getId(rootAccess) == id)</TD></TR><TR><TD CLASS="l">843</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">844</TD><TD>                        return answer;</TD></TR><TR><TD CLASS="l">845</TD><TD>                }</TD></TR><TR><TD CLASS="l">846</TD><TD>                else</TD></TR><TR><TD CLASS="l">847</TD><TD>                {                        </TD></TR><TR><TD CLASS="l">848</TD><TD>                        //Node is not part of the Hypeerweb</TD></TR><TR CLASS="c"><TD CLASS="l">849</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">850</TD><TD>                }</TD></TR><TR><TD CLASS="l">851</TD><TD>        }</TD></TR><TR><TD CLASS="l">852</TD><TD>        </TD></TR><TR><TD CLASS="l">853</TD><TD>        /**</TD></TR><TR><TD CLASS="l">854</TD><TD>         * inserts the node into the HyPeerWeb</TD></TR><TR><TD CLASS="l">855</TD><TD>         * @param insertNode - node to be inserted</TD></TR><TR><TD CLASS="l">856</TD><TD>         * @pre insertNode != null</TD></TR><TR><TD CLASS="l"><A NAME="a">857</A></TD><TD>         * @post insertNode is now the last node in the HyPeerWeb and satisfies the UML diagram</TD></TR><TR><TD CLASS="l">858</TD><TD>         */</TD></TR><TR><TD CLASS="l">859</TD><TD>        public void insert(Node insertNode) throws InterruptedException</TD></TR><TR><TD CLASS="l">860</TD><TD>        {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">861</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert insertNode != null;</TD></TR><TR><TD CLASS="l">862</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">863</TD><TD>                Node insertionPoint = null;</TD></TR><TR CLASS="c"><TD CLASS="l">864</TD><TD>                while (insertionPoint == null)</TD></TR><TR><TD CLASS="l">865</TD><TD>                {</TD></TR><TR><TD CLASS="l">866</TD><TD>                        try</TD></TR><TR><TD CLASS="l">867</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">868</TD><TD>                                insertionPoint = this.getInsertionPoint();</TD></TR><TR><TD CLASS="l">869</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">870</TD><TD>                        catch (NullPointerException e)</TD></TR><TR><TD CLASS="l">871</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">872</TD><TD>                                System.out.println(&#34;Error trying to find Insertion Point. Trying again.&#34;);</TD></TR><TR><TD CLASS="l">873</TD><TD>                        }</TD></TR><TR><TD CLASS="l">874</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">875</TD><TD>                insertionPoint.performInsert(insertNode);</TD></TR><TR CLASS="c"><TD CLASS="l">876</TD><TD>        }</TD></TR><TR><TD CLASS="l">877</TD><TD>        </TD></TR><TR><TD CLASS="l">878</TD><TD>        /**</TD></TR><TR><TD CLASS="l">879</TD><TD>         * Method to run the main algorithm to insert a node to the HyPeerWeb</TD></TR><TR><TD CLASS="l">880</TD><TD>         * @param insertNode - the node to be inserted to the HyPeerWeb</TD></TR><TR><TD CLASS="l">881</TD><TD>         * @throws InterruptedException</TD></TR><TR><TD CLASS="l">882</TD><TD>         * @pre insertNode != null</TD></TR><TR><TD CLASS="l">883</TD><TD>         * @post insertNode is inserted into the HyPeerWeb at the insertion point</TD></TR><TR><TD CLASS="l">884</TD><TD>         */</TD></TR><TR><TD CLASS="l"><A NAME="2c">885</A></TD><TD>        public void performInsert(Node insertNode) throws InterruptedException</TD></TR><TR><TD CLASS="l">886</TD><TD>        {</TD></TR><TR><TD CLASS="l">887</TD><TD>                try</TD></TR><TR><TD CLASS="l">888</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">889</TD><TD>                        FileOutputStream fos = new FileOutputStream(&#34;log.txt&#34;, true);</TD></TR><TR CLASS="c"><TD CLASS="l">890</TD><TD>                        java.io.PrintStream oos = new java.io.PrintStream(fos);</TD></TR><TR CLASS="c"><TD CLASS="l">891</TD><TD>                        oos.print(&#34;Starting insert at insertion point &#34; + this.id + &#34;\n&#34;);</TD></TR><TR><TD CLASS="l">892</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">893</TD><TD>                catch (java.io.IOException e)</TD></TR><TR><TD CLASS="l">894</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">895</TD><TD>                        System.out.println(&#34;Error writing removal string to file.&#34;);</TD></TR><TR><TD CLASS="l">896</TD><TD>                }</TD></TR><TR><TD CLASS="l">897</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">898</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="c"><TD CLASS="l">899</TD><TD>                insertNode.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">900</TD><TD>                this.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">901</TD><TD>                this.fold.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">902</TD><TD>                if(this.oldFold != null)</TD></TR><TR><TD CLASS="l">903</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">904</TD><TD>                        this.oldFold.beingModified(true);</TD></TR><TR><TD CLASS="l">905</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">906</TD><TD>                NodeList insertionUpPointers = this.getUpPointers(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">907</TD><TD>                NodeList insertionNeighbours = this.getNeighbours(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">908</TD><TD>                for(Node neighbour : insertionNeighbours)</TD></TR><TR><TD CLASS="l">909</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">910</TD><TD>                        neighbour.beingModified(true);</TD></TR><TR><TD CLASS="l">911</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">912</TD><TD>                for(Node upPointer : insertionUpPointers)</TD></TR><TR><TD CLASS="l">913</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">914</TD><TD>                        upPointer.beingModified(true);</TD></TR><TR><TD CLASS="l">915</TD><TD>                }</TD></TR><TR><TD CLASS="l">916</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">917</TD><TD>                insertNode.setId(this.getId(rootAccess) + (int) Math.pow(2, this.getHeight(rootAccess)));</TD></TR><TR><TD CLASS="l">918</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">919</TD><TD>                this.insertionFoldSetup(this, insertNode);</TD></TR><TR><TD CLASS="l">920</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">921</TD><TD>                if(insertNode.getFold(rootAccess).getId(rootAccess) != 0)</TD></TR><TR><TD CLASS="l">922</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">923</TD><TD>                        for(Node node : this.getNeighbours(rootAccess))</TD></TR><TR><TD CLASS="l">924</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">925</TD><TD>                                if(node.getChild(rootAccess) == null)</TD></TR><TR><TD CLASS="l">926</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">927</TD><TD>                                        insertNode.setDownPointer(node);</TD></TR><TR CLASS="c"><TD CLASS="l">928</TD><TD>                                        node.setUpPointer(insertNode);</TD></TR><TR CLASS="c"><TD CLASS="l">929</TD><TD>                                        node.setState(UpState.getState());</TD></TR><TR><TD CLASS="l">930</TD><TD>                                }</TD></TR><TR><TD CLASS="l">931</TD><TD>                        }</TD></TR><TR><TD CLASS="l">932</TD><TD>                }</TD></TR><TR><TD CLASS="l">933</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">934</TD><TD>                if(insertionUpPointers.size() &gt; 0)</TD></TR><TR><TD CLASS="l">935</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">936</TD><TD>                        insertNode.addNeighbours(insertionUpPointers);</TD></TR><TR CLASS="c"><TD CLASS="l">937</TD><TD>                        for(Node node : insertionUpPointers)</TD></TR><TR><TD CLASS="l">938</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">939</TD><TD>                                NodeList downPointers = node.getDownPointers(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">940</TD><TD>                                downPointers.remove(this);</TD></TR><TR CLASS="c"><TD CLASS="l">941</TD><TD>                                node.setDownPointers(downPointers);</TD></TR><TR CLASS="c"><TD CLASS="l">942</TD><TD>                                node.addNeighbour(insertNode);</TD></TR><TR CLASS="c"><TD CLASS="l">943</TD><TD>                                if(node.getDownPointers(rootAccess).size() == 0)</TD></TR><TR><TD CLASS="l">944</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">945</TD><TD>                                        node.setState(EmptyState.getState());</TD></TR><TR><TD CLASS="l">946</TD><TD>                                }</TD></TR><TR CLASS="c"><TD CLASS="l">947</TD><TD>                                node.beingModified(false);</TD></TR><TR><TD CLASS="l">948</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">949</TD><TD>                        insertionUpPointers.clear();</TD></TR><TR CLASS="c"><TD CLASS="l">950</TD><TD>                        this.setUpPointers(insertionUpPointers);</TD></TR><TR CLASS="c"><TD CLASS="l">951</TD><TD>                        this.setState(EmptyState.getState());</TD></TR><TR><TD CLASS="l">952</TD><TD>                }</TD></TR><TR><TD CLASS="l">953</TD><TD>                </TD></TR><TR><TD CLASS="l">954</TD><TD>                //sets this node as added Node's parent</TD></TR><TR CLASS="c"><TD CLASS="l">955</TD><TD>                insertNode.addNeighbour(this);</TD></TR><TR><TD CLASS="l">956</TD><TD>                //set insertNode as child</TD></TR><TR CLASS="c"><TD CLASS="l">957</TD><TD>                this.addNeighbour(insertNode);</TD></TR><TR><TD CLASS="l">958</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">959</TD><TD>                insertNode.renewState();</TD></TR><TR><TD CLASS="l">960</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">961</TD><TD>                for(Node neighbour : insertionNeighbours)</TD></TR><TR><TD CLASS="l">962</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">963</TD><TD>                        neighbour.beingModified(false);</TD></TR><TR><TD CLASS="l">964</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">965</TD><TD>                this.beingModified(false);</TD></TR><TR CLASS="c"><TD CLASS="l">966</TD><TD>                insertNode.beingModified(false);</TD></TR><TR CLASS="c"><TD CLASS="l">967</TD><TD>                this.fold.beingModified(false);</TD></TR><TR CLASS="c"><TD CLASS="l">968</TD><TD>                insertNode.getFold(rootAccess).beingModified(false);</TD></TR><TR CLASS="c"><TD CLASS="l">969</TD><TD>                if(this.oldFold != null)</TD></TR><TR><TD CLASS="l">970</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">971</TD><TD>                        this.oldFold.beingModified(false);</TD></TR><TR><TD CLASS="l">972</TD><TD>                }</TD></TR><TR><TD CLASS="l">973</TD><TD>                </TD></TR><TR><TD CLASS="l">974</TD><TD>                try</TD></TR><TR><TD CLASS="l">975</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">976</TD><TD>                        FileOutputStream fos = new FileOutputStream(&#34;log.txt&#34;, true);</TD></TR><TR CLASS="c"><TD CLASS="l">977</TD><TD>                        java.io.PrintStream oos = new java.io.PrintStream(fos);</TD></TR><TR CLASS="c"><TD CLASS="l">978</TD><TD>                        oos.print(&#34;Ending insert at insertion point &#34; + this.id + &#34;\n&#34;);</TD></TR><TR><TD CLASS="l">979</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">980</TD><TD>                catch (java.io.IOException e)</TD></TR><TR><TD CLASS="l">981</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">982</TD><TD>                        System.out.println(&#34;Error writing removal string to file.&#34;);</TD></TR><TR><TD CLASS="l">983</TD><TD>                }</TD></TR><TR><TD CLASS="l">984</TD><TD>                </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="91% line coverage (32 out of 35 instructions)">985</TD><TD TITLE="91% line coverage (32 out of 35 instructions)">                synchronized (this)</TD></TR><TR><TD CLASS="l">986</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">987</TD><TD>                        Semaphore lock = (Semaphore) this.getPayload(&#34;busy&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">988</TD><TD>                        lock.release();</TD></TR><TR><TD CLASS="l">989</TD><TD>                        </TD></TR><TR><TD CLASS="l">990</TD><TD>                        //sets payload in the next Insertion Point</TD></TR><TR CLASS="c"><TD CLASS="l">991</TD><TD>                        Node nextInsertion = new Node();</TD></TR><TR CLASS="c"><TD CLASS="l">992</TD><TD>                        if(this.id == (int) Math.pow(2, neighbours.size() - 1) - 1)</TD></TR><TR><TD CLASS="l">993</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">994</TD><TD>                                if(this.id != 0)</TD></TR><TR><TD CLASS="l">995</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">996</TD><TD>                                        nextInsertion = find(0, this, rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">997</TD><TD>                                        nextInsertion.setPayload(&#34;busy&#34;, lock);</TD></TR><TR CLASS="c"><TD CLASS="l">998</TD><TD>                                        this.setPayload(&#34;busy&#34;, null);</TD></TR><TR><TD CLASS="l">999</TD><TD>                                }</TD></TR><TR><TD CLASS="l">1000</TD><TD>                                else</TD></TR><TR><TD CLASS="l">1001</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">1002</TD><TD>                                        this.setPayload(&#34;busy&#34;, lock);</TD></TR><TR><TD CLASS="l">1003</TD><TD>                                }</TD></TR><TR><TD CLASS="l">1004</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1005</TD><TD>                        else</TD></TR><TR><TD CLASS="l">1006</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1007</TD><TD>                                nextInsertion = find(this.id + 1, this, rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1008</TD><TD>                                nextInsertion.setPayload(&#34;busy&#34;, lock);</TD></TR><TR CLASS="c"><TD CLASS="l">1009</TD><TD>                                this.setPayload(&#34;busy&#34;, null);</TD></TR><TR><TD CLASS="l">1010</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1011</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1012</TD><TD>        }</TD></TR><TR><TD CLASS="l">1013</TD><TD>        </TD></TR><TR><TD CLASS="l">1014</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1015</TD><TD>         * Sets the fold and old fold of the insertion point Node and the node that is to be inserted</TD></TR><TR><TD CLASS="l">1016</TD><TD>         * appropriately</TD></TR><TR><TD CLASS="l">1017</TD><TD>         * @param insertionPoint the Node where a new Node will be inserted</TD></TR><TR><TD CLASS="l">1018</TD><TD>         * @param insertNode The new Node that is being inserted into the Hypeer Web</TD></TR><TR><TD CLASS="l">1019</TD><TD>         * @pre insertionPoint is the insertion Point in the Hypeer Web this Node is connected to.</TD></TR><TR><TD CLASS="l">1020</TD><TD>         * insertNode is a new Node that is being inserted into the current Hypeer Web.</TD></TR><TR><TD CLASS="l"><A NAME="2e">1021</A></TD><TD>         * @post The fold and old fold are set correctly in insertionPoint and insertNode</TD></TR><TR><TD CLASS="l">1022</TD><TD>         */</TD></TR><TR><TD CLASS="l">1023</TD><TD>        public void insertionFoldSetup(Node insertionPoint, Node insertNode)throws InterruptedException</TD></TR><TR><TD CLASS="l">1024</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1025</TD><TD>                boolean rootAccess = true;</TD></TR><TR><TD CLASS="l">1026</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1027</TD><TD>                Assert.assertTrue(insertNode.getDownPointers(rootAccess).size() == 0 </TD></TR><TR CLASS="c"><TD CLASS="l">1028</TD><TD>                                &amp;&amp; insertNode.getUpPointers(rootAccess).size() == 0 </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="88% line coverage (7 out of 8 instructions)">1029</TD><TD TITLE="88% line coverage (7 out of 8 instructions)">                                &amp;&amp; insertNode.getNeighbours(rootAccess).size() == 0);</TD></TR><TR><TD CLASS="l">1030</TD><TD>                //assert this.getInsertionPoint() == insertionPoint;</TD></TR><TR><TD CLASS="l">1031</TD><TD>                </TD></TR><TR><TD CLASS="l">1032</TD><TD>                //set folds</TD></TR><TR><TD CLASS="l">1033</TD><TD>                // first case is for the first insert in a size one HyPeerWeb</TD></TR><TR CLASS="c"><TD CLASS="l">1034</TD><TD>                if(insertionPoint.getFold(rootAccess).getId(rootAccess) == insertionPoint.getId(rootAccess))</TD></TR><TR><TD CLASS="l">1035</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1036</TD><TD>                        insertNode.setFold(insertionPoint);</TD></TR><TR CLASS="c"><TD CLASS="l">1037</TD><TD>                        insertionPoint.setFold(insertNode);</TD></TR><TR><TD CLASS="l">1038</TD><TD>                }</TD></TR><TR><TD CLASS="l">1039</TD><TD>                else</TD></TR><TR><TD CLASS="l">1040</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1041</TD><TD>                        if(insertionPoint.getOldFold() == null)</TD></TR><TR><TD CLASS="l">1042</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1043</TD><TD>                                insertNode.setFold(insertionPoint.getFold(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1044</TD><TD>                                insertionPoint.getFold(rootAccess).setFold(insertNode);</TD></TR><TR CLASS="c"><TD CLASS="l">1045</TD><TD>                                insertionPoint.getFold(rootAccess).setOldFold(insertionPoint);</TD></TR><TR><TD CLASS="l">1046</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1047</TD><TD>                        else</TD></TR><TR><TD CLASS="l">1048</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1049</TD><TD>                                insertNode.setFold(insertionPoint.getOldFold());</TD></TR><TR CLASS="c"><TD CLASS="l">1050</TD><TD>                                insertNode.getFold(rootAccess).setFold(insertNode);</TD></TR><TR CLASS="c"><TD CLASS="l">1051</TD><TD>                                insertionPoint.setOldFold(null);</TD></TR><TR><TD CLASS="l">1052</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1053</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1054</TD><TD>        }        </TD></TR><TR><TD CLASS="l">1055</TD><TD>        </TD></TR><TR><TD CLASS="l">1056</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1057</TD><TD>         * returns string representation of this node</TD></TR><TR><TD CLASS="l">1058</TD><TD>         * @return string representation of this node</TD></TR><TR><TD CLASS="l">1059</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l">1060</TD><TD>         * @post return string representation of this node </TD></TR><TR><TD CLASS="l"><A NAME="2a">1061</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">1062</TD><TD>        public String toString()</TD></TR><TR><TD CLASS="l">1063</TD><TD>        {</TD></TR><TR><TD CLASS="l">1064</TD><TD>                String result;</TD></TR><TR CLASS="c"><TD CLASS="l">1065</TD><TD>                boolean rootAccess = false;</TD></TR><TR><TD CLASS="l">1066</TD><TD>                try</TD></TR><TR><TD CLASS="l">1067</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1068</TD><TD>                        result = &#34;[Node: &#34; + this.getId(rootAccess) + &#34;]&#34;;</TD></TR><TR><TD CLASS="l">1069</TD><TD>                 </TD></TR><TR CLASS="c"><TD CLASS="l">1070</TD><TD>                        result += String.format(&#34;%-25s&#34;, &#34; Neighbours: &#34; </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="97% line coverage (61 out of 63 instructions)">1071</TD><TD TITLE="97% line coverage (61 out of 63 instructions)">                                        + (getNeighbours(rootAccess) == null ? &#34;&#34; : getNeighbours(rootAccess).toString()));  </TD></TR><TR CLASS="c"><TD CLASS="l">1072</TD><TD>                        result += String.format(&#34;%-21s&#34;,  &#34; Up: &#34; </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="96% line coverage (54 out of 56 instructions)">1073</TD><TD TITLE="96% line coverage (54 out of 56 instructions)">                                        + (this.getUpPointers(rootAccess) == null ? &#34;&#34; : this.getUpPointers(rootAccess).toString())); </TD></TR><TR CLASS="c"><TD CLASS="l">1074</TD><TD>                        result += String.format(&#34;%-25s&#34;, &#34; Down: &#34; </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="96% line coverage (54 out of 56 instructions)">1075</TD><TD TITLE="96% line coverage (54 out of 56 instructions)">                                        + (this.getDownPointers(rootAccess) == null ? &#34;&#34; : this.getDownPointers(rootAccess).toString())); </TD></TR><TR CLASS="c"><TD CLASS="l">1076</TD><TD>                        result += String.format(&#34;%-10s&#34;, &#34;        Fold: &#34; </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="96% line coverage (55 out of 57 instructions)">1077</TD><TD TITLE="96% line coverage (55 out of 57 instructions)">                                        + (this.getFold(rootAccess) == null ? &#34;&lt;&gt;&#34; : this.getFold(rootAccess).getId(rootAccess))); </TD></TR><TR CLASS="c"><TD CLASS="l">1078</TD><TD>                        result += String.format(&#34;%-20s&#34;, &#34; OldFold: &#34; </TD></TR><TR CLASS="c"><TD CLASS="l">1079</TD><TD>                                        + (this.getOldFold() == null ? &#34;&lt;&gt;&#34; : this.getOldFold().getId(rootAccess))); </TD></TR><TR CLASS="c"><TD CLASS="l">1080</TD><TD>                        result += String.format(&#34;%-20s&#34;, &#34; State: &lt;&#34; + this.getState(rootAccess) + &#34;&gt;&#34;);</TD></TR><TR><TD CLASS="l">1081</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">1082</TD><TD>                catch (InterruptedException e)</TD></TR><TR><TD CLASS="l">1083</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1084</TD><TD>                        result = &#34;Node was in an invalid state and this thread terminated before a valid state was reached.&#34;;</TD></TR><TR><TD CLASS="l">1085</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1086</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">1087</TD><TD>                //return &#34;Node: &#34; + id;</TD></TR><TR><TD CLASS="l">1088</TD><TD>                </TD></TR><TR><TD CLASS="l">1089</TD><TD>        }</TD></TR><TR><TD CLASS="l">1090</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1091</TD><TD>         * Prints all nodes in a Hypeer Web connected to this node</TD></TR><TR><TD CLASS="l">1092</TD><TD>         * @return string representation of the HyPeerWeb</TD></TR><TR><TD CLASS="l">1093</TD><TD>         * @pre None</TD></TR><TR><TD CLASS="l">1094</TD><TD>         * @post return string representation of all nodes connected to this node</TD></TR><TR><TD CLASS="l"><A NAME="39">1095</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">1096</TD><TD>        @SuppressWarnings(&#34;unchecked&#34;)</TD></TR><TR><TD CLASS="l">1097</TD><TD>        public String printAllNode() throws InterruptedException</TD></TR><TR><TD CLASS="l">1098</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1099</TD><TD>                boolean rootAccess = false;</TD></TR><TR><TD CLASS="l">1100</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1101</TD><TD>                ArrayList&lt;Node&gt; recipients = new ArrayList&lt;Node&gt;();</TD></TR><TR CLASS="c"><TD CLASS="l">1102</TD><TD>                plugin.BroadcastAlgorithm broadcast = new plugin.BroadcastAlgorithm();</TD></TR><TR CLASS="c"><TD CLASS="l">1103</TD><TD>                recipients = (ArrayList&lt;Node&gt;) this.acceptWithResponse(broadcast, this.getId(rootAccess));</TD></TR><TR><TD CLASS="l">1104</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1105</TD><TD>                NodeList allNodes = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">1106</TD><TD>                allNodes.addAll(this.allNodes(recipients, this.getId(rootAccess)));</TD></TR><TR><TD CLASS="l">1107</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1108</TD><TD>                String result = &#34;&#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">1109</TD><TD>                for(Node node : allNodes)</TD></TR><TR><TD CLASS="l">1110</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1111</TD><TD>                        result += node.toString() + &#34;\n&#34;;</TD></TR><TR><TD CLASS="l">1112</TD><TD>                }</TD></TR><TR><TD CLASS="l">1113</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1114</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">1115</TD><TD>        }</TD></TR><TR><TD CLASS="l">1116</TD><TD> </TD></TR><TR><TD CLASS="l">1117</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1118</TD><TD>         * Returns list of all nodes connected to this one</TD></TR><TR><TD CLASS="l">1119</TD><TD>         * @return all nodes connected to this one</TD></TR><TR><TD CLASS="l">1120</TD><TD>         * @pre current node/up/down/neighbor not null</TD></TR><TR><TD CLASS="l">1121</TD><TD>         * @post return list of nodes connected to this one</TD></TR><TR><TD CLASS="l">1122</TD><TD>         */</TD></TR><TR><TD CLASS="l">1123</TD><TD>        @SuppressWarnings(&#34;unchecked&#34;)</TD></TR><TR><TD CLASS="l"><A NAME="32">1124</A></TD><TD>        private NodeList allNodes(ArrayList&lt;Node&gt; recipients, int startNodeID) throws InterruptedException</TD></TR><TR><TD CLASS="l">1125</TD><TD>        {</TD></TR><TR><TD CLASS="l">1126</TD><TD>                //assert this.getUpPointers() != null &amp;&amp; this.getDownPointers() != null &amp;&amp; this.getNeighbours() != null; </TD></TR><TR><TD CLASS="l">1127</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1128</TD><TD>                plugin.BroadcastAlgorithm broadcast = new plugin.BroadcastAlgorithm();</TD></TR><TR CLASS="c"><TD CLASS="l">1129</TD><TD>                NodeList result = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">1130</TD><TD>                ArrayList&lt;Node&gt; nextRecipients = new ArrayList&lt;Node&gt;();</TD></TR><TR><TD CLASS="l">1131</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1132</TD><TD>                result.add(this);</TD></TR><TR CLASS="c"><TD CLASS="l">1133</TD><TD>                for(Node node : recipients)</TD></TR><TR><TD CLASS="l">1134</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1135</TD><TD>                        nextRecipients = (ArrayList&lt;Node&gt;) node.acceptWithResponse(broadcast, startNodeID);</TD></TR><TR CLASS="c"><TD CLASS="l">1136</TD><TD>                        result.addAll(node.allNodes(nextRecipients, startNodeID));</TD></TR><TR><TD CLASS="l">1137</TD><TD>                }</TD></TR><TR><TD CLASS="l">1138</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1139</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">1140</TD><TD>        }</TD></TR><TR><TD CLASS="l">1141</TD><TD>        </TD></TR><TR><TD CLASS="l">1142</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1143</TD><TD>         * This method removes the node from the HyPeerWeb </TD></TR><TR><TD CLASS="l">1144</TD><TD>         * and replaces it with the last node from the HyPeerWeb</TD></TR><TR><TD CLASS="l">1145</TD><TD>         * @return the node that replaced the removed Node</TD></TR><TR><TD CLASS="l">1146</TD><TD>         * @pre this node is part of a HyPeerWeb and this node's height is </TD></TR><TR><TD CLASS="l">1147</TD><TD>         * greater than 0</TD></TR><TR><TD CLASS="l"><A NAME="26">1148</A></TD><TD>         * @post return the Node that was removed from HyPeerWeb</TD></TR><TR><TD CLASS="l">1149</TD><TD>         */</TD></TR><TR><TD CLASS="l">1150</TD><TD>        public Node remove() throws InterruptedException</TD></TR><TR><TD CLASS="l">1151</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1152</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="33% line coverage (4 out of 12 instructions)">1153</TD><TD TITLE="33% line coverage (4 out of 12 instructions)">                assert this.getHeight(rootAccess) &gt; 0;</TD></TR><TR><TD CLASS="l">1154</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1155</TD><TD>                Node insertionPoint = null;</TD></TR><TR CLASS="c"><TD CLASS="l">1156</TD><TD>                while (insertionPoint == null)</TD></TR><TR><TD CLASS="l">1157</TD><TD>                {</TD></TR><TR><TD CLASS="l">1158</TD><TD>                        try</TD></TR><TR><TD CLASS="l">1159</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1160</TD><TD>                                insertionPoint = this.getInsertionPoint();</TD></TR><TR><TD CLASS="l">1161</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">1162</TD><TD>                        catch (NullPointerException e)</TD></TR><TR><TD CLASS="l">1163</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">1164</TD><TD>                                System.out.println(&#34;Error finding Insertion Point. Trying again.&#34;);</TD></TR><TR><TD CLASS="l">1165</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1166</TD><TD>                        </TD></TR><TR><TD CLASS="l">1167</TD><TD>                }</TD></TR><TR><TD CLASS="l">1168</TD><TD> </TD></TR><TR><TD CLASS="l">1169</TD><TD>                try</TD></TR><TR><TD CLASS="l">1170</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1171</TD><TD>                        FileOutputStream fos = new FileOutputStream(&#34;log.txt&#34;, true);</TD></TR><TR CLASS="c"><TD CLASS="l">1172</TD><TD>                        java.io.PrintStream oos = new java.io.PrintStream(fos);</TD></TR><TR CLASS="c"><TD CLASS="l">1173</TD><TD>                        oos.print(&#34;Starting removal of &#34; + this.id + &#34;\n&#34;);</TD></TR><TR><TD CLASS="l">1174</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">1175</TD><TD>                catch (java.io.IOException e)</TD></TR><TR><TD CLASS="l">1176</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1177</TD><TD>                        System.out.println(&#34;Error writing removal string to file.&#34;);</TD></TR><TR><TD CLASS="l">1178</TD><TD>                }</TD></TR><TR><TD CLASS="l">1179</TD><TD>                //set All Nodes to be changed to the invalid State</TD></TR><TR CLASS="c"><TD CLASS="l">1180</TD><TD>                NodeList modified = new NodeList();</TD></TR><TR CLASS="c"><TD CLASS="l">1181</TD><TD>                this.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1182</TD><TD>                modified.add(this);</TD></TR><TR CLASS="c"><TD CLASS="l">1183</TD><TD>                for(Node node : this.neighbours)</TD></TR><TR><TD CLASS="l">1184</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1185</TD><TD>                        node.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1186</TD><TD>                        modified.add(node);</TD></TR><TR><TD CLASS="l">1187</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1188</TD><TD>                for(Node node : this.up)</TD></TR><TR><TD CLASS="l">1189</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1190</TD><TD>                        node.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1191</TD><TD>                        modified.add(node);</TD></TR><TR><TD CLASS="l">1192</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1193</TD><TD>                for(Node node : this.down)</TD></TR><TR><TD CLASS="l">1194</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1195</TD><TD>                        node.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1196</TD><TD>                        modified.add(node);</TD></TR><TR><TD CLASS="l">1197</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1198</TD><TD>                this.fold.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1199</TD><TD>                modified.add(this.fold);</TD></TR><TR CLASS="c"><TD CLASS="l">1200</TD><TD>                if(this.oldFold != null)</TD></TR><TR><TD CLASS="l">1201</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1202</TD><TD>                        this.oldFold.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1203</TD><TD>                        modified.add(this.oldFold);</TD></TR><TR><TD CLASS="l">1204</TD><TD>                }</TD></TR><TR><TD CLASS="l">1205</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">1206</TD><TD>                Node lastNode = insertionPoint.getLastNode();</TD></TR><TR><TD CLASS="l">1207</TD><TD>                //get previous insertion point</TD></TR><TR CLASS="c"><TD CLASS="l">1208</TD><TD>                Node prevInsertionPoint = lastNode.getParent(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1209</TD><TD>                if(prevInsertionPoint == this)</TD></TR><TR><TD CLASS="l">1210</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1211</TD><TD>                        prevInsertionPoint = lastNode;</TD></TR><TR><TD CLASS="l">1212</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1213</TD><TD>                lastNode.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1214</TD><TD>                modified.add(lastNode);</TD></TR><TR CLASS="c"><TD CLASS="l">1215</TD><TD>                prevInsertionPoint.beingModified(true);</TD></TR><TR CLASS="c"><TD CLASS="l">1216</TD><TD>                modified.add(prevInsertionPoint);</TD></TR><TR CLASS="c"><TD CLASS="l">1217</TD><TD>                modified.addAll(lastNode.getNeighbours(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1218</TD><TD>                modified.addAll(lastNode.getDownPointers(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1219</TD><TD>                modified.add(lastNode.getFold(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1220</TD><TD>                lastNode.removeLastNode();</TD></TR><TR><TD CLASS="l">1221</TD><TD>                //System.out.println(&#34;After removing last node: \n&#34; + this.printAllNode());</TD></TR><TR><TD CLASS="l">1222</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1223</TD><TD>                Node returnNode = lastNode.equals(this) ? this : lastNode.replaceNode(this);</TD></TR><TR><TD CLASS="l">1224</TD><TD>                </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="89% line coverage (25 out of 28 instructions)">1225</TD><TD TITLE="89% line coverage (25 out of 28 instructions)">                synchronized (this)</TD></TR><TR><TD CLASS="l">1226</TD><TD>                {</TD></TR><TR><TD CLASS="l">1227</TD><TD>                        //unlock insertion Point and set in the new Insertion Point</TD></TR><TR CLASS="c"><TD CLASS="l">1228</TD><TD>                        Semaphore lock = (Semaphore) insertionPoint.getPayload(&#34;busy&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">1229</TD><TD>                        lock.release();</TD></TR><TR CLASS="c"><TD CLASS="l">1230</TD><TD>                        prevInsertionPoint.setPayload(&#34;busy&#34;, lock);</TD></TR><TR CLASS="c"><TD CLASS="l">1231</TD><TD>                        insertionPoint.setPayload(&#34;busy&#34;, null);</TD></TR><TR><TD CLASS="l">1232</TD><TD>                }</TD></TR><TR><TD CLASS="l">1233</TD><TD>                </TD></TR><TR><TD CLASS="l">1234</TD><TD>                try</TD></TR><TR><TD CLASS="l">1235</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1236</TD><TD>                        FileOutputStream fos = new FileOutputStream(&#34;log.txt&#34;, true);</TD></TR><TR CLASS="c"><TD CLASS="l">1237</TD><TD>                        java.io.PrintStream oos = new java.io.PrintStream(fos);</TD></TR><TR CLASS="c"><TD CLASS="l">1238</TD><TD>                        oos.print(&#34;Ending removal of &#34; + this.id + &#34;\n&#34;);</TD></TR><TR><TD CLASS="l">1239</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">1240</TD><TD>                catch (java.io.IOException e)</TD></TR><TR><TD CLASS="l">1241</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1242</TD><TD>                        System.out.println(&#34;Error writing removal string to file.&#34;);</TD></TR><TR><TD CLASS="l">1243</TD><TD>                }</TD></TR><TR><TD CLASS="l">1244</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1245</TD><TD>                for(Node node : modified)</TD></TR><TR><TD CLASS="l">1246</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1247</TD><TD>                        node.beingModified(false);</TD></TR><TR><TD CLASS="l">1248</TD><TD>                }</TD></TR><TR><TD CLASS="l">1249</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1250</TD><TD>                return returnNode;</TD></TR><TR><TD CLASS="l">1251</TD><TD>        }</TD></TR><TR><TD CLASS="l">1252</TD><TD>        </TD></TR><TR><TD CLASS="l">1253</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1254</TD><TD>         * overrides the writeReplace() in serializable to funciton for nodes</TD></TR><TR><TD CLASS="l">1255</TD><TD>         * @return the NodeProxy created for this Node</TD></TR><TR><TD CLASS="l">1256</TD><TD>         * @throws ObjectStreamException</TD></TR><TR><TD CLASS="l">1257</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="7">1258</A></TD><TD>         * @post return a NodeProxy for this node</TD></TR><TR><TD CLASS="l">1259</TD><TD>         */</TD></TR><TR><TD CLASS="l">1260</TD><TD>        public Object writeReplace() throws ObjectStreamException</TD></TR><TR><TD CLASS="l">1261</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">1262</TD><TD>                NodeProxy p = new NodeProxy(this.globalID, this.id);</TD></TR><TR CLASS="z"><TD CLASS="l">1263</TD><TD>                return p;</TD></TR><TR><TD CLASS="l">1264</TD><TD>        }</TD></TR><TR><TD CLASS="l">1265</TD><TD>        </TD></TR><TR><TD CLASS="l">1266</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1267</TD><TD>         * returns a NodeProxy for this node</TD></TR><TR><TD CLASS="l">1268</TD><TD>         * @return a NodeProxy for this node</TD></TR><TR><TD CLASS="l">1269</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="4">1270</A></TD><TD>         * @post return a NodeProxy for this node, proxy.globalID = this.globalID &amp;&amp; proxy.id = this.id</TD></TR><TR><TD CLASS="l">1271</TD><TD>         */</TD></TR><TR><TD CLASS="l">1272</TD><TD>        public NodeProxy getProxy()</TD></TR><TR><TD CLASS="l">1273</TD><TD>        {</TD></TR><TR CLASS="z"><TD CLASS="l">1274</TD><TD>                return new NodeProxy(this.globalID, this.id);</TD></TR><TR><TD CLASS="l">1275</TD><TD>        }</TD></TR><TR><TD CLASS="l">1276</TD><TD>        </TD></TR><TR><TD CLASS="l">1277</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1278</TD><TD>         * Returns the last Node in the Hypeer Web</TD></TR><TR><TD CLASS="l">1279</TD><TD>         * @return Node object that is the Last Node in the Hypeer Web the current Node is connected to.</TD></TR><TR><TD CLASS="l">1280</TD><TD>         * @pre The Node that calls this function is the Insertion Point</TD></TR><TR><TD CLASS="l"><A NAME="29">1281</A></TD><TD>         * @post Last Node in the HypeerWeb this Node is connected to is returned.</TD></TR><TR><TD CLASS="l">1282</TD><TD>         */</TD></TR><TR><TD CLASS="l">1283</TD><TD>        public Node getLastNode() throws InterruptedException</TD></TR><TR><TD CLASS="l">1284</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1285</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="c"><TD CLASS="l">1286</TD><TD>                if(this.getId(rootAccess) == 0 &amp;&amp; this.getNeighbours(rootAccess).size() == 0)</TD></TR><TR><TD CLASS="l">1287</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1288</TD><TD>                        return this;</TD></TR><TR><TD CLASS="l">1289</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1290</TD><TD>                else if(this.getId(rootAccess) == 0)</TD></TR><TR><TD CLASS="l">1291</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1292</TD><TD>                        return this.getFold(rootAccess);</TD></TR><TR><TD CLASS="l">1293</TD><TD>                }</TD></TR><TR><TD CLASS="l">1294</TD><TD>                else</TD></TR><TR><TD CLASS="l">1295</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1296</TD><TD>                        Node tmp = find(this.getId(rootAccess) - 1, this, rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1297</TD><TD>                        return tmp.getChild(rootAccess);</TD></TR><TR><TD CLASS="l">1298</TD><TD>                }</TD></TR><TR><TD CLASS="l">1299</TD><TD>                </TD></TR><TR><TD CLASS="l">1300</TD><TD>        }</TD></TR><TR><TD CLASS="l">1301</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1302</TD><TD>         * Removes the current Node from the Hypeer Web by removing all it's pointers to other Nodes.</TD></TR><TR><TD CLASS="l">1303</TD><TD>         * @return The Node just removed from it's position in the Hypeer Web</TD></TR><TR><TD CLASS="l">1304</TD><TD>         * @pre the calling Node is the Node with the highest ID in the hypeer web</TD></TR><TR><TD CLASS="l"><A NAME="3c">1305</A></TD><TD>         * @post return the last node in the HyPeerWeb with all its connections severed</TD></TR><TR><TD CLASS="l">1306</TD><TD>         */</TD></TR><TR><TD CLASS="l">1307</TD><TD>        public Node removeLastNode() throws InterruptedException</TD></TR><TR><TD CLASS="l">1308</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1309</TD><TD>                boolean rootAccess = true;</TD></TR><TR><TD CLASS="l">1310</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1311</TD><TD>                for(Node neighbour : this.neighbours)</TD></TR><TR><TD CLASS="l">1312</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1313</TD><TD>                        neighbour.beingModified(true);</TD></TR><TR><TD CLASS="l">1314</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1315</TD><TD>                for(Node downPointer : this.down)</TD></TR><TR><TD CLASS="l">1316</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1317</TD><TD>                        downPointer.beingModified(true);</TD></TR><TR><TD CLASS="l">1318</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1319</TD><TD>                this.fold.beingModified(true);</TD></TR><TR><TD CLASS="l">1320</TD><TD>                </TD></TR><TR><TD CLASS="l">1321</TD><TD>                //this will change to emptystate</TD></TR><TR><TD CLASS="l">1322</TD><TD>                //System.out.println(&#34;--&#34; +  getId());</TD></TR><TR CLASS="c"><TD CLASS="l">1323</TD><TD>                this.setState(EmptyState.getState());</TD></TR><TR><TD CLASS="l">1324</TD><TD>                //neighbors remove this and point to my surgate</TD></TR><TR CLASS="c"><TD CLASS="l">1325</TD><TD>                Iterator&lt;Node&gt; it = this.getNeighbours(rootAccess).iterator();</TD></TR><TR CLASS="c"><TD CLASS="l">1326</TD><TD>                while (it.hasNext())</TD></TR><TR><TD CLASS="l">1327</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1328</TD><TD>                        Node temp = it.next();</TD></TR><TR CLASS="c"><TD CLASS="l">1329</TD><TD>                        temp.removeNeighbor(this);</TD></TR><TR><TD CLASS="l">1330</TD><TD>                        </TD></TR><TR><TD CLASS="l">1331</TD><TD>                }</TD></TR><TR><TD CLASS="l">1332</TD><TD>                </TD></TR><TR><TD CLASS="l">1333</TD><TD>                //if no neighbor, then the down nodes will change to downstate.</TD></TR><TR><TD CLASS="l">1334</TD><TD>                //down pointers should remove their pointer to lastNode</TD></TR><TR CLASS="c"><TD CLASS="l">1335</TD><TD>                it = this.getDownPointers(rootAccess).iterator();</TD></TR><TR CLASS="c"><TD CLASS="l">1336</TD><TD>                while (it.hasNext())</TD></TR><TR><TD CLASS="l">1337</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1338</TD><TD>                        Node temp = it.next();</TD></TR><TR CLASS="c"><TD CLASS="l">1339</TD><TD>                        temp.removeUp(this);</TD></TR><TR><TD CLASS="l">1340</TD><TD>                }</TD></TR><TR><TD CLASS="l">1341</TD><TD>                //last node has no up pointers, right?</TD></TR><TR><TD CLASS="l">1342</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1343</TD><TD>                if(this.getFold(rootAccess) != null)</TD></TR><TR><TD CLASS="l">1344</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1345</TD><TD>                        this.getFold(rootAccess).removeFold(this);</TD></TR><TR><TD CLASS="l">1346</TD><TD>                }</TD></TR><TR><TD CLASS="l">1347</TD><TD>                //fold.fold = fold.oldfold</TD></TR><TR><TD CLASS="l">1348</TD><TD>                //fold.oldfold= null</TD></TR><TR><TD CLASS="l">1349</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1350</TD><TD>                return this;</TD></TR><TR><TD CLASS="l">1351</TD><TD>        }</TD></TR><TR><TD CLASS="l">1352</TD><TD>        </TD></TR><TR><TD CLASS="l">1353</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1354</TD><TD>         * removes the node from this list of neighbours</TD></TR><TR><TD CLASS="l">1355</TD><TD>         * @param node The node that is being removed</TD></TR><TR><TD CLASS="l">1356</TD><TD>         * @pre node != null</TD></TR><TR><TD CLASS="l"><A NAME="3d">1357</A></TD><TD>         * @post node is removed from this nodes list of neighbours</TD></TR><TR><TD CLASS="l">1358</TD><TD>         */</TD></TR><TR><TD CLASS="l">1359</TD><TD>        public void removeNeighbor(Node node) throws InterruptedException</TD></TR><TR><TD CLASS="l">1360</TD><TD>        {         </TD></TR><TR CLASS="c"><TD CLASS="l">1361</TD><TD>                boolean rootAccess = true;</TD></TR><TR><TD CLASS="l">1362</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1363</TD><TD>                if(this.equals(node.getParent(rootAccess)))</TD></TR><TR><TD CLASS="l">1364</TD><TD>                {         </TD></TR><TR CLASS="c"><TD CLASS="l">1365</TD><TD>                        NodeList nei = node.getNeighbours(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1366</TD><TD>                         this.getUpPointers(rootAccess).addAll(nei);</TD></TR><TR CLASS="c"><TD CLASS="l">1367</TD><TD>                         this.getUpPointers(rootAccess).remove(this);</TD></TR><TR CLASS="c"><TD CLASS="l">1368</TD><TD>                         this.setState(UpState.getState());</TD></TR><TR><TD CLASS="l">1369</TD><TD>                }</TD></TR><TR><TD CLASS="l">1370</TD><TD>                else</TD></TR><TR><TD CLASS="l">1371</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1372</TD><TD>                        this.getDownPointers(rootAccess).add(node.getParent(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1373</TD><TD>                        this.setState(DownState.getState());</TD></TR><TR><TD CLASS="l">1374</TD><TD>        </TD></TR><TR><TD CLASS="l">1375</TD><TD>                }</TD></TR><TR><TD CLASS="l">1376</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1377</TD><TD>                this.getNeighbours(rootAccess).remove(node);</TD></TR><TR><TD CLASS="l">1378</TD><TD>                </TD></TR><TR><TD CLASS="l">1379</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1380</TD><TD>                renewState();</TD></TR><TR><TD CLASS="l">1381</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1382</TD><TD>        }</TD></TR><TR><TD CLASS="l">1383</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1384</TD><TD>         * Removes an Up Pointers from the current Node that mathes the param, node</TD></TR><TR><TD CLASS="l">1385</TD><TD>         * @param node</TD></TR><TR><TD CLASS="l">1386</TD><TD>         * @pre node != null</TD></TR><TR><TD CLASS="l"><A NAME="15">1387</A></TD><TD>         * @post current Node no longer has an Up Pointer to node &amp;&amp; state of current Node is updated correctly</TD></TR><TR><TD CLASS="l">1388</TD><TD>         */</TD></TR><TR><TD CLASS="l">1389</TD><TD>        public void removeUp(Node node) throws InterruptedException</TD></TR><TR><TD CLASS="l">1390</TD><TD>        {  </TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">1391</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert node != null;</TD></TR><TR CLASS="c"><TD CLASS="l">1392</TD><TD>                boolean rootAccess = true;</TD></TR><TR><TD CLASS="l">1393</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1394</TD><TD>                this.getUpPointers(rootAccess).remove(node);</TD></TR><TR><TD CLASS="l">1395</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1396</TD><TD>                if(this.getUpPointers(rootAccess).size() == 0)</TD></TR><TR><TD CLASS="l">1397</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1398</TD><TD>                        this.setState(DownState.getState());</TD></TR><TR><TD CLASS="l">1399</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1400</TD><TD>                renewState();</TD></TR><TR CLASS="c"><TD CLASS="l">1401</TD><TD>        }</TD></TR><TR><TD CLASS="l">1402</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1403</TD><TD>         * removes the current fold and replaces it with the next logical node</TD></TR><TR><TD CLASS="l">1404</TD><TD>         * @param node - the fold to be removed</TD></TR><TR><TD CLASS="l">1405</TD><TD>         * @pre node != null</TD></TR><TR><TD CLASS="l">1406</TD><TD>         * @post this.fold is assigned the next logical node to be the fold</TD></TR><TR><TD CLASS="l"><A NAME="3b">1407</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">1408</TD><TD>        public void removeFold(Node node) throws InterruptedException</TD></TR><TR><TD CLASS="l">1409</TD><TD>        { </TD></TR><TR><TD CLASS="l">1410</TD><TD>                //System.out.println(&#34;f&#34;+id +&#34; &#34; + fold + &#34;|&#34; + oldFold+&#34;child&#34;+giveMeChild());</TD></TR><TR CLASS="c"><TD CLASS="l">1411</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="c"><TD CLASS="l">1412</TD><TD>                if(this.giveMeChild(rootAccess) != null)</TD></TR><TR><TD CLASS="l">1413</TD><TD>                {</TD></TR><TR><TD CLASS="l">1414</TD><TD>                        //System.out.println(&#34;giveMeChild() != null&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">1415</TD><TD>                        this.setFold(node.getParent(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1416</TD><TD>                        this.setOldFold(null);</TD></TR><TR CLASS="c"><TD CLASS="l">1417</TD><TD>                        this.getFold(rootAccess).setOldFold(this);</TD></TR><TR CLASS="c"><TD CLASS="l">1418</TD><TD>                        Node child = this.giveMeChild(rootAccess);</TD></TR><TR><TD CLASS="l">1419</TD><TD>                         </TD></TR><TR CLASS="c"><TD CLASS="l">1420</TD><TD>                        this.getFold(rootAccess).setFold(child);</TD></TR><TR><TD CLASS="l">1421</TD><TD>                } </TD></TR><TR><TD CLASS="l">1422</TD><TD>                else</TD></TR><TR><TD CLASS="l">1423</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1424</TD><TD>                        this.setFold(node.getParent(rootAccess));</TD></TR><TR CLASS="c"><TD CLASS="l">1425</TD><TD>                        this.setOldFold(null);</TD></TR><TR CLASS="c"><TD CLASS="l">1426</TD><TD>                        this.getFold(rootAccess).setOldFold(null);</TD></TR><TR><TD CLASS="l">1427</TD><TD>                }</TD></TR><TR><TD CLASS="l">1428</TD><TD>                //System.out.println(this.getId() + &#34;'s Fold updated to: &#34; + fold.getId());</TD></TR><TR CLASS="c"><TD CLASS="l">1429</TD><TD>                renewState();</TD></TR><TR CLASS="c"><TD CLASS="l">1430</TD><TD>        }</TD></TR><TR><TD CLASS="l">1431</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1432</TD><TD>         * Determine the current state and reassign it </TD></TR><TR><TD CLASS="l">1433</TD><TD>         * @pre none</TD></TR><TR><TD CLASS="l"><A NAME="2b">1434</A></TD><TD>         * @post state of the current node is assigned correctly</TD></TR><TR><TD CLASS="l">1435</TD><TD>         */</TD></TR><TR><TD CLASS="l">1436</TD><TD>        public void renewState() throws InterruptedException</TD></TR><TR><TD CLASS="l">1437</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1438</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="c"><TD CLASS="l">1439</TD><TD>                if(this.getUpPointers(rootAccess).size() == 0 &amp;&amp; this.getDownPointers(rootAccess).size() == 0)</TD></TR><TR><TD CLASS="l">1440</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1441</TD><TD>                        this.setState(EmptyState.getState());</TD></TR><TR CLASS="c"><TD CLASS="l">1442</TD><TD>                        if (this.getNeighbours(rootAccess).size() &gt; 0 </TD></TR><TR CLASS="c"><TD CLASS="l">1443</TD><TD>                                        &amp;&amp; this.getId(rootAccess) &gt; this.getNeighbours(rootAccess).getMax().getId(rootAccess))</TD></TR><TR><TD CLASS="l">1444</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1445</TD><TD>                                this.setState(LastState.getState());</TD></TR><TR><TD CLASS="l">1446</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1447</TD><TD>                        </TD></TR><TR><TD CLASS="l">1448</TD><TD>                } </TD></TR><TR CLASS="c"><TD CLASS="l">1449</TD><TD>                else if(this.getUpPointers(rootAccess).size() &gt; 0)</TD></TR><TR><TD CLASS="l">1450</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1451</TD><TD>                        this.setState(UpState.getState());</TD></TR><TR><TD CLASS="l">1452</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1453</TD><TD>                else if(this.getDownPointers(rootAccess).size() &gt; 0)</TD></TR><TR><TD CLASS="l">1454</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1455</TD><TD>                        this.setState(DownState.getState());</TD></TR><TR><TD CLASS="l">1456</TD><TD>                }</TD></TR><TR><TD CLASS="l">1457</TD><TD>                else</TD></TR><TR><TD CLASS="l">1458</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1459</TD><TD>                        this.setState(EmptyState.getState());</TD></TR><TR><TD CLASS="l">1460</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1461</TD><TD>        }</TD></TR><TR><TD CLASS="l">1462</TD><TD>        </TD></TR><TR><TD CLASS="l">1463</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1464</TD><TD>         * Replaces the passed in Node with itself</TD></TR><TR><TD CLASS="l">1465</TD><TD>         * @param other the Node to replace</TD></TR><TR><TD CLASS="l">1466</TD><TD>         * @return this Node</TD></TR><TR><TD CLASS="l">1467</TD><TD>         * @pre other != null;</TD></TR><TR><TD CLASS="l"><A NAME="2d">1468</A></TD><TD>         * @post All pointers in the Node, other, are transfered to the current Node</TD></TR><TR><TD CLASS="l">1469</TD><TD>         */</TD></TR><TR><TD CLASS="l">1470</TD><TD>        public Node replaceNode(Node other) throws InterruptedException</TD></TR><TR><TD CLASS="l">1471</TD><TD>        {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="25% line coverage (2 out of 8 instructions)">1472</TD><TD TITLE="25% line coverage (2 out of 8 instructions)">                assert other != null;</TD></TR><TR><TD CLASS="l">1473</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1474</TD><TD>                boolean rootAccess = true;</TD></TR><TR CLASS="c"><TD CLASS="l">1475</TD><TD>                this.id = other.getId(rootAccess);                </TD></TR><TR CLASS="c"><TD CLASS="l">1476</TD><TD>                this.state = other.getState(rootAccess);</TD></TR><TR><TD CLASS="l">1477</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1478</TD><TD>                this.neighbours.clear();</TD></TR><TR CLASS="c"><TD CLASS="l">1479</TD><TD>                this.neighbours.addAll(other.getNeighbours(rootAccess));</TD></TR><TR><TD CLASS="l">1480</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1481</TD><TD>                this.up.clear();</TD></TR><TR CLASS="c"><TD CLASS="l">1482</TD><TD>                this.up.addAll(other.getUpPointers(rootAccess));</TD></TR><TR><TD CLASS="l">1483</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1484</TD><TD>                this.down.clear();</TD></TR><TR CLASS="c"><TD CLASS="l">1485</TD><TD>                this.down.addAll(other.getDownPointers(rootAccess));</TD></TR><TR><TD CLASS="l">1486</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1487</TD><TD>                this.fold = other.getFold(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1488</TD><TD>                this.oldFold = other.getOldFold();</TD></TR><TR><TD CLASS="l">1489</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1490</TD><TD>                this.payload.clear();</TD></TR><TR CLASS="c"><TD CLASS="l">1491</TD><TD>                this.payload.putAll(other.getWholePayload());</TD></TR><TR><TD CLASS="l">1492</TD><TD>                </TD></TR><TR><TD CLASS="l">1493</TD><TD>                // update neighbour pointers</TD></TR><TR CLASS="c"><TD CLASS="l">1494</TD><TD>                for (Node neighbour : this.neighbours)</TD></TR><TR><TD CLASS="l">1495</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1496</TD><TD>                        NodeList neighbourNodeList = neighbour.getNeighbours(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1497</TD><TD>                        neighbourNodeList.replace(other, this);</TD></TR><TR CLASS="c"><TD CLASS="l">1498</TD><TD>                        neighbour.setNeighbours(neighbourNodeList);</TD></TR><TR><TD CLASS="l">1499</TD><TD>                }</TD></TR><TR><TD CLASS="l">1500</TD><TD>                // update down pointers to this node</TD></TR><TR CLASS="c"><TD CLASS="l">1501</TD><TD>                for (Node upPointer : this.up)</TD></TR><TR><TD CLASS="l">1502</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1503</TD><TD>                        NodeList upPointerNodeList = upPointer.getDownPointers(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1504</TD><TD>                        upPointerNodeList.replace(other, this);</TD></TR><TR CLASS="c"><TD CLASS="l">1505</TD><TD>                        upPointer.setDownPointers(upPointerNodeList);</TD></TR><TR><TD CLASS="l">1506</TD><TD>                }</TD></TR><TR><TD CLASS="l">1507</TD><TD>                // update up pointers to this node</TD></TR><TR CLASS="c"><TD CLASS="l">1508</TD><TD>                for (Node downPointer : this.down)</TD></TR><TR><TD CLASS="l">1509</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1510</TD><TD>                        NodeList downPointerNodeList = downPointer.getUpPointers(rootAccess);</TD></TR><TR CLASS="c"><TD CLASS="l">1511</TD><TD>                        downPointerNodeList.replace(other, this);</TD></TR><TR CLASS="c"><TD CLASS="l">1512</TD><TD>                        downPointer.setUpPointers(downPointerNodeList);</TD></TR><TR><TD CLASS="l">1513</TD><TD>                }</TD></TR><TR><TD CLASS="l">1514</TD><TD>                </TD></TR><TR><TD CLASS="l">1515</TD><TD>                // updates folds, takes care of case where this </TD></TR><TR><TD CLASS="l">1516</TD><TD>                // might be the fold's oldFold</TD></TR><TR CLASS="c"><TD CLASS="l">1517</TD><TD>                if (this.fold.getFold(rootAccess).compareTo(other) == 0)</TD></TR><TR><TD CLASS="l">1518</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1519</TD><TD>                        this.fold.getFold(rootAccess).setFold(this);</TD></TR><TR CLASS="c"><TD CLASS="l">1520</TD><TD>                        this.fold.setFold(this);</TD></TR><TR><TD CLASS="l">1521</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1522</TD><TD>                else if (this.fold.getOldFold() != null &amp;&amp; this.fold.getOldFold().compareTo(other) == 0)</TD></TR><TR><TD CLASS="l">1523</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1524</TD><TD>                        this.fold.setOldFold(this);</TD></TR><TR><TD CLASS="l">1525</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1526</TD><TD>                if (this.oldFold != null)</TD></TR><TR><TD CLASS="l">1527</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1528</TD><TD>                        this.oldFold.setFold(this);</TD></TR><TR><TD CLASS="l">1529</TD><TD>                }</TD></TR><TR><TD CLASS="l">1530</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">1531</TD><TD>                this.state.assertState(this);</TD></TR><TR><TD CLASS="l">1532</TD><TD>                </TD></TR><TR><TD CLASS="l">1533</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">1534</TD><TD>                return this;</TD></TR><TR><TD CLASS="l">1535</TD><TD>        }</TD></TR><TR><TD CLASS="l">1536</TD><TD>        </TD></TR><TR><TD CLASS="l">1537</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1538</TD><TD>         * @pre true</TD></TR><TR><TD CLASS="l">1539</TD><TD>         * @post Node has no getter commands currently being executed and the Node can be modified</TD></TR><TR><TD CLASS="l">1540</TD><TD>         * @param state - </TD></TR><TR><TD CLASS="l"><A NAME="f">1541</A></TD><TD>         * @throws InterruptedException</TD></TR><TR><TD CLASS="l">1542</TD><TD>         */</TD></TR><TR><TD CLASS="l">1543</TD><TD>        public void beingModified(boolean state) throws InterruptedException</TD></TR><TR><TD CLASS="l">1544</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1545</TD><TD>                boolean tryAgain = true;</TD></TR><TR CLASS="c"><TD CLASS="l">1546</TD><TD>                while (tryAgain)</TD></TR><TR><TD CLASS="l">1547</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1548</TD><TD>                        if(accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">1549</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">1550</TD><TD>                                this.modifyingCommands.acquire();</TD></TR><TR><TD CLASS="l">1551</TD><TD>                        }</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="77% line coverage (10 out of 13 instructions)">1552</TD><TD TITLE="77% line coverage (10 out of 13 instructions)">                        synchronized (this)</TD></TR><TR><TD CLASS="l">1553</TD><TD>                        {</TD></TR><TR CLASS="c"><TD CLASS="l">1554</TD><TD>                                if(accessingData &gt; 0)</TD></TR><TR><TD CLASS="l">1555</TD><TD>                                {</TD></TR><TR CLASS="z"><TD CLASS="l">1556</TD><TD>                                        tryAgain = true;</TD></TR><TR CLASS="z"><TD CLASS="l">1557</TD><TD>                                        continue;</TD></TR><TR><TD CLASS="l">1558</TD><TD>                                }</TD></TR><TR><TD CLASS="l">1559</TD><TD>                                else</TD></TR><TR><TD CLASS="l">1560</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">1561</TD><TD>                                        tryAgain = false;</TD></TR><TR><TD CLASS="l">1562</TD><TD>                                }</TD></TR><TR CLASS="c"><TD CLASS="l">1563</TD><TD>                                if(state)</TD></TR><TR><TD CLASS="l">1564</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">1565</TD><TD>                                        beingModified = state;</TD></TR><TR><TD CLASS="l">1566</TD><TD>                                }</TD></TR><TR><TD CLASS="l">1567</TD><TD>                                else</TD></TR><TR><TD CLASS="l">1568</TD><TD>                                {</TD></TR><TR CLASS="c"><TD CLASS="l">1569</TD><TD>                                        beingModified = state;</TD></TR><TR CLASS="c"><TD CLASS="l">1570</TD><TD>                                        while (access.hasQueuedThreads())</TD></TR><TR><TD CLASS="l">1571</TD><TD>                                        {</TD></TR><TR CLASS="z"><TD CLASS="l">1572</TD><TD>                                                access.release();</TD></TR><TR><TD CLASS="l">1573</TD><TD>                                        }</TD></TR><TR><TD CLASS="l">1574</TD><TD>                                }</TD></TR><TR><TD CLASS="l">1575</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1576</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1577</TD><TD>        }</TD></TR><TR><TD CLASS="l">1578</TD><TD>        </TD></TR><TR><TD CLASS="l">1579</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1580</TD><TD>         * @pre true</TD></TR><TR><TD CLASS="l">1581</TD><TD>         * @post true is the node this is called on is the insertion point and false, otherwise</TD></TR><TR><TD CLASS="l"><A NAME="1d">1582</A></TD><TD>         * @return true is the node this is called on is the insertion point and false, otherwise</TD></TR><TR><TD CLASS="l">1583</TD><TD>         */</TD></TR><TR><TD CLASS="l">1584</TD><TD>        public synchronized boolean getInsertionLock()</TD></TR><TR><TD CLASS="l">1585</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1586</TD><TD>                Semaphore busy = (Semaphore) this.getPayload(&#34;busy&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">1587</TD><TD>                if (busy == null || !busy.tryAcquire())</TD></TR><TR><TD CLASS="l">1588</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1589</TD><TD>                        return false;</TD></TR><TR><TD CLASS="l">1590</TD><TD>                }</TD></TR><TR><TD CLASS="l">1591</TD><TD>                else</TD></TR><TR><TD CLASS="l">1592</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1593</TD><TD>                        return true;</TD></TR><TR><TD CLASS="l">1594</TD><TD>                }</TD></TR><TR><TD CLASS="l">1595</TD><TD>        }</TD></TR><TR><TD CLASS="l">1596</TD><TD>        </TD></TR><TR><TD CLASS="l">1597</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1598</TD><TD>         * @pre accessingData &gt; 0</TD></TR><TR><TD CLASS="l">1599</TD><TD>         * @post accessingData' == accessingData - 1 &amp;&amp; </TD></TR><TR><TD CLASS="l">1600</TD><TD>         *                 all nodes waiting to modify node are released if accessingData == 0 </TD></TR><TR><TD CLASS="l"><A NAME="1b">1601</A></TD><TD>         *</TD></TR><TR><TD CLASS="l">1602</TD><TD>         */</TD></TR><TR><TD CLASS="l">1603</TD><TD>        public synchronized void releaseAccessPriviledge()</TD></TR><TR><TD CLASS="l">1604</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1605</TD><TD>                accessingData--;</TD></TR><TR CLASS="c"><TD CLASS="l">1606</TD><TD>                if(accessingData == 0)</TD></TR><TR><TD CLASS="l">1607</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1608</TD><TD>                        while (modifyingCommands.hasQueuedThreads())</TD></TR><TR><TD CLASS="l">1609</TD><TD>                        {</TD></TR><TR CLASS="z"><TD CLASS="l">1610</TD><TD>                                modifyingCommands.release();</TD></TR><TR><TD CLASS="l">1611</TD><TD>                        }</TD></TR><TR><TD CLASS="l">1612</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">1613</TD><TD>        }</TD></TR><TR><TD CLASS="l">1614</TD><TD>        </TD></TR><TR><TD CLASS="l">1615</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1616</TD><TD>         * @pre true</TD></TR><TR><TD CLASS="l">1617</TD><TD>         * @post no modifying commands on the Node will currently be taking place</TD></TR><TR><TD CLASS="l">1618</TD><TD>         * @param rootAccess</TD></TR><TR><TD CLASS="l"><A NAME="21">1619</A></TD><TD>         * @return</TD></TR><TR><TD CLASS="l">1620</TD><TD>         */</TD></TR><TR><TD CLASS="l">1621</TD><TD>        public synchronized boolean acquireAccessPriviledge(boolean rootAccess)</TD></TR><TR><TD CLASS="l">1622</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1623</TD><TD>                if(!rootAccess &amp;&amp; this.beingModified)</TD></TR><TR><TD CLASS="l">1624</TD><TD>                {</TD></TR><TR CLASS="z"><TD CLASS="l">1625</TD><TD>                        return false;</TD></TR><TR><TD CLASS="l">1626</TD><TD>                }</TD></TR><TR><TD CLASS="l">1627</TD><TD>                else</TD></TR><TR><TD CLASS="l">1628</TD><TD>                {</TD></TR><TR CLASS="c"><TD CLASS="l">1629</TD><TD>                        accessingData++;</TD></TR><TR CLASS="c"><TD CLASS="l">1630</TD><TD>                        return true;</TD></TR><TR><TD CLASS="l">1631</TD><TD>                }</TD></TR><TR><TD CLASS="l">1632</TD><TD>        }</TD></TR><TR><TD CLASS="l">1633</TD><TD>        </TD></TR><TR><TD CLASS="l">1634</TD><TD>        /**</TD></TR><TR><TD CLASS="l">1635</TD><TD>         * Prints a message from the node</TD></TR><TR><TD CLASS="l">1636</TD><TD>         * @param message - the message to be printed by the node</TD></TR><TR><TD CLASS="l">1637</TD><TD>         * @pre message != null</TD></TR><TR><TD CLASS="l"><A NAME="3a">1638</A></TD><TD>         * @post the node prints the message</TD></TR><TR><TD CLASS="l">1639</TD><TD>         */</TD></TR><TR><TD CLASS="l">1640</TD><TD>        public void printMessage(String message)</TD></TR><TR><TD CLASS="l">1641</TD><TD>        {</TD></TR><TR CLASS="c"><TD CLASS="l">1642</TD><TD>                System.out.println(&#34;Node &#34; + id + &#34; received message: &#34; + message);</TD></TR><TR CLASS="c"><TD CLASS="l">1643</TD><TD>        }</TD></TR><TR><TD CLASS="l">1644</TD><TD>}</TD></TR></TABLE><P></P><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="nv">[<A HREF="../cs340omegaReportApril.html">all classes</A>][<A HREF="3.html">Phase2</A>]</TD></TR><TR><TD CLASS="tl"><A HREF="http://www.eclemma.org/support.html">EMMA 2.0.5312 EclEmma Fix 1</A> (C) Vladimir Roubtsov</TD></TR></TABLE></BODY></HTML>